Transaction
Transactions are used to manipulate multiple SQL for some operations as atomic, and once an error occurs, it can be rolled back to its original state, guaranteeing database data integrity.
Transaction instance:
CREATE TABLE User (IDintPRIMARY Key Auto_increment,nameChar(32), Balanceint) insert into user (Name,balance) VALUES (' Big wood ', 1000),(' Two wooden wood ', 1000),(' Miki ', 1000); #原子操作start transaction;update user Set balance=900 where name= ' large wooden wood '; #买支付100元update User Set Balance=1010 where name= ' two wood wood '; #中介拿走10元update User Set Balance=1090 where name= ' Tri-wood '; #卖家拿到90元commit; #出现异常, roll back to the initial state start transaction;update user set balance=900 where name= ' large wooden wood '; #买支付100元update User Set Balance=1010 where name= ' two wood wood '; #中介拿走10元uppdate User Set Balance=1090 where name= ' Tri-wood '; #卖家拿到90元, the exception did not get rollback; #回到原来的状态commit, MySQL> select *from user;+----+------+---------+| ID | name | Balance |+----+------+---------+| 1 | Big Wood Wood | 1000 | | 2 | Two Wood Wood | 1000 | | 3 | Miki Wood | |+----+------+---------+3 rows in Set (0.00 sec)
Attached: Mysql basic usage
First, "Mysql Basic usage view"
Second, "Mysql basic usage of the trigger"
Third, "Mysql basic usage of the business"
Iv. "Stored Procedures for Mysql basic usage"
V. "Functions of basic Mysql usage"
Vi. "Mysql Basic usage Process Control"
Knowledge Point: Mysql basic usage of the business