zoukankan      html  css  js  c++  java
  • autocommit=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)
  • 相关阅读:
    一LWIP学习笔记之数据包管理
    智能家居的发展趋势
    break和continue的区别
    TCP与UDP区别总结
    C语言变量和函数命名规范
    常用电子元件
    php 1018
    php 1016
    mysql 应用查询 三个表(学生表,课程表,学生课程分数表) student, course, score表
    mysql 聚合函数
  • 原文地址:https://www.cnblogs.com/zengkefu/p/5637727.html
Copyright © 2011-2022 走看看