Four characteristics of transactions in mysql

Atomicity (Atomicity)

Affairs like "atomic" Like, can not be divided, the composition of the transaction DML statements either all operations succeed, or all three fail, the case of partial failure partial success impossible.

Consistency (Consistency)

Once the transaction is completed, regardless of success or failure, the entire system is in a consistent state of data.

Isolation (Isolation)

Execution of a transaction is not another firm interference. For example, two people from withdrawing money from one account to ensure the correctness of the account balance by transaction isolation.

Persistent (Durability)

Also known as permanent, it means that once a transaction commits, changes to the data is permanent and can no longer be rolled back.

 

MySQL's transactional There are two main methods
1. begin, rollback, commit to realize
    begin start a transaction
    rollback transaction rollback
    commit the transaction commits
2. Direct use MySQL set to change the automatic submission mode
    MySQL default is automatically submitted, also that you submit a sql, direct execution! Can be
    set autocommit = disable automatic submission 0
    set autocommit = 1 enable auto-commit
    processing to realize the transaction.

But pay attention when using autocommit set = 0, and after all the sql will be handled as a transaction until the confirmation commit or rollback end, note that when the end of the transaction but also opens up new business! Only the first method as a current affairs!

Guess you like

Origin www.cnblogs.com/lengjiayuan/p/11546330.html