Mariadb Affairs

Affairs

Transaction has ACID properties: Atomicity (A, atomicity), consistency (C, consistency), isolation (I, isolation), persistent (D, durabulity).

1, atomic: either all operations within a transaction are executed or not executed, it is an indivisible unit of work.

2, the consistency of: a transition from the state database is always consistent state to another consistent (which in the previous example, the consistency is ensured, even in the implementation of a system crash between the third, four statements, checking account also no loss of $ 200, because things are not ultimately submitted, so things will not save the changes made to the database)

3, isolation: a firm to make changes before final submission, other transactions are not visible (in the previous example, when the complete implementation of the third statement, the fourth sentence has not yet started, there is at this time Another account rollup starts running, it saw the balance of the checking account has not been minus $ 200.)

4. Durability: after the transaction is completed, the data involved in the transaction must be written to disk to ensure the persistence of their persistence. Of course, this is from the perspective of the persistence of the matters to be considered, from the operating system or hardware failure, it is not necessarily.

Verify isolation; (open transaction, transfers simulated environment)

1> create a table and add data

 

2> View affairs variable (show variables can be used to view system variable)

 

on: auto-commit

3> Open Service (two ways to begin; start transaction;) does not automatically turn submit the transaction, the memory operation in which

 

4> transfer simulation

 

$

 

5> look at a terminal View

 

& Open transaction and transfer simulation

 

You will find that the card has been, until an error

This is because the transaction isolation, mutual interference is not

6> to close the transaction (written to disk)

 

7> View

 

# View another terminal

 

Why not change? Because the transaction is still in them, we need to end the transaction

 

& Simulate power failure transfer

1> On matters

2> Transfer

 

3> Analog power failure

 

4> re-enter the database

 

5> View

 

Will find the turn out is back, this is because, from the beginning this is begin a transaction, or to perform all the success, or failure to have a full failure.

失败后于做了一次回滚 ( rollback)( 相当于咱们什么都没操作)

6>这时候则需要人为 来调整下

 

注: 结束事务有两种方法,commit ;   rollback;(回滚)

补充:

&1

这里默认 ON       在不开启  begin 的情况下 每执行一条seq 语句都会自动提交事务

改变它的默认参数

&1永久方法

编辑配置文件 

vim  /etc/my.cnf.d/server.cnf

 

0  : 关闭

重启数据库并查看

 

&2临时修改

set  xxxx = 0

补充2: show variables ;

查看系统变量 ( 参数)

 

Guess you like

Origin www.cnblogs.com/myxxjie/p/10960327.html