#commit and rollback are used to ensure that the database has enough space left;
#commi, rollback can only be used for DML operations, that is, insert, UPDATE, delet;
#rollback操作撤销上一个commit, rollback after the transaction.
CREATE TABLE Test
(
prod_id varchar (TEN) is not NULL,
Prod_desc varchar (+) NULL,
Cost decimal (6,2) null
);
#禁止自动提交
Set autocommit=0;
#设置事务特性, must be set before all transactions begin
#set transaction Read only; #设置事务只读
Set transaction read write; #设置事务可读, write
#开始一次事务
Start transaction;
INSERT INTO Test
VALUES (' 4456 ', ' Mr Right ', 46.97);
Commit #位置1
INSERT INTO Test
VALUES (' 3345 ', ' Mr Wrong ', 54.90);
Rollback #回到位置1, (position 2); last Commit
INSERT INTO Test
VALUES (' 1111 ', ' Mr Wan ', 89.76);
Rollback #回到位置2, last rollback place.
#测试保存点savepoint
SavePoint point1;
Update test
Set prod_id=1;
Rollback to Point1; #回到保存点point1
Release SavePoint point1; #删除保存点
drop table test;
MySQL Things roll back