What is a transaction? How MySQL support transactions?

A transaction is a step in the sequence of operations or steps databases into logical execution units , this series of operations either all executed or give up all executed.

Procedures and transactions are two different concepts. In general: a program may contain multiple transactions . ( It means the logic operation execution unit few database constituted )

 

Transaction has four properties : Atomicity (Atomicity), consistency (Consistency), isolation (Isolation) and persistent (Durability). These four characteristics are also referred to as the ACID properties.

 

(1) Atomic : application transaction is the smallest unit of execution, as is the nature of the smallest particles atoms, having the same characteristics can not be divided. Application of the transaction is not subdivided smallest logical execution bodies. ( Minimum, and can not be divided up )

(2) Consistency : a transaction result of execution, the database must be consistent from one state to another consistent state variable. When the database contains only the outcome of the transaction successfully committed, the database is in a consistent state.

        Consistency is ensured by atomicity. ( Having said that the white dog into a black dog, can not appear Dalmatians! )

(3) Isolation : performing interfering each transaction, a transaction of any other internal operations of concurrent transactions, is isolated.

         In other words: You can not see the other side of the intermediate state between transactions to execute concurrently, and can not influence each other concurrently executing transactions. ( To put it plainly, what you do you, I do my! )

(4) sustained : also known as persistent persistence, means that once a transaction commits, any changes made to the data, to be recorded in the persistent memory, usually saved to the physical database . ( It means a road went black )

 

How MySQL support transactions?

MYSQL transactions have mainly two kinds of methods

  1. begin, rollback, commit to realize
    begin start a transaction
    rollback transaction rollback
       commit a transaction confirmation
  2. Direct use set to change the automatic submission mode mysql
          mysql default is automatically submitted, that is, you submit a query, direct execution ! By
          0 = disable automatic submission autocommit the SET
          the SET autocommit = 1 turn on automatic submission
       process to achieve affairs

Guess you like

Origin www.cnblogs.com/Rivend/p/12089526.html