首页 > 其他 > 详细

autocommit=0

时间:2016-07-03 11:49:12      阅读:167      评论:0      收藏:0      [点我收藏+]
mysql> set autocommit=0;
Query OK, 0 rows affected (0.00 sec)

mysql> create table test( a int);
Query OK, 0 rows affected (0.20 sec)

mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| tab_test       |
| tab_test1      |
| tab_test4      |
| test           |
+----------------+
4 rows in set (0.00 sec)

mysql> rollback;                                 //不回滚DDL
Query OK, 0 rows affected (0.00 sec)

mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| tab_test       |
| tab_test1      |
| tab_test4      |
| test           |
+----------------+
4 rows in set (0.00 sec)



误插入回滚: mysql
> insert into test select 1; Query OK, 1 row affected (0.00 sec) Records: 1 Duplicates: 0 Warnings: 0 mysql> insert into test select 2; Query OK, 1 row affected (0.00 sec) Records: 1 Duplicates: 0 Warnings: 0 mysql> insert into test select 3; Query OK, 1 row affected (0.00 sec) Records: 1 Duplicates: 0 Warnings: 0 mysql> select * from test; +------+ | a | +------+ | 1 | | 2 | | 3 | +------+ 3 rows in set (0.00 sec) mysql> rollback; Query OK, 0 rows affected (0.19 sec) mysql> select * from test; Empty set (0.01 sec)






误删除回滚: mysql
> insert into test select 1; Query OK, 1 row affected (0.00 sec) Records: 1 Duplicates: 0 Warnings: 0 mysql> insert into test select 2; Query OK, 1 row affected (0.00 sec) Records: 1 Duplicates: 0 Warnings: 0 mysql> insert into test select 3; Query OK, 1 row affected (0.00 sec) Records: 1 Duplicates: 0 Warnings: 0 mysql> commit; Query OK, 0 rows affected (0.15 sec) mysql> select * from test; +------+ | a | +------+ | 1 | | 2 | | 3 | +------+ 3 rows in set (0.00 sec) mysql> delete from test; Query OK, 3 rows affected (0.00 sec) mysql> select * from test; Empty set (0.00 sec) mysql> rollback; Query OK, 0 rows affected (0.17 sec) mysql> select * from test; +------+ | a | +------+ | 1 | | 2 | | 3 | +------+ 3 rows in set (0.00 sec)

 

autocommit=0

原文:http://www.cnblogs.com/zengkefu/p/5637727.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!