在autocommit=1的情况下,开启一个事务,如果里面有DDL语句,那么事务开始到DDL语句之间的DML语句都会被提交。再开启新的事务。可以从binlog中看出
 
session语句:
09:26:04 root@localhost:[testdb] mysql.sock>select * from t2;
+------+--------+-------+
| id   | course | score |
+------+--------+-------+
|    1 | math   |     0 |
|    2 | ch     |     0 |
|    3 | eng    |     0 |
+------+--------+-------+
3 rows in set (0.00 sec)
 
09:26:10 root@localhost:[testdb] mysql.sock>begin;
Query OK, 0 rows affected (0.00 sec)
 
09:26:18 root@localhost:[testdb] mysql.sock>delete from t2 where id=2;
Query OK, 1 row affected (0.05 sec)
 
09:26:30 root@localhost:[testdb] mysql.sock>alter table t2 drop column score;
Query OK, 0 rows affected (0.11 sec)
Records: 0  Duplicates: 0  Warnings: 0
 
09:26:43 root@localhost:[testdb] mysql.sock>delete from t2 where id=3;
Query OK, 1 row affected (0.00 sec)
 
09:26:53 root@localhost:[testdb] mysql.sock>delete from t2 where id=1;
Query OK, 1 row affected (0.03 sec)
 
09:27:30 root@localhost:[testdb] mysql.sock>rollback;
Query OK, 0 rows affected (0.00 sec)
 
09:27:37 root@localhost:[testdb] mysql.sock>select * from t2;
Empty set (0.00 sec)
 
 
 mysqlbinlog解析:
 
[root@zejin240 mysql]# mysqlbinlog --no-defaults -v --base64-output=DECODE-ROWS good.000001 
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#160510  9:26:03 server id 4  end_log_pos 120 CRC32 0xfb18f530     Start: binlog v 4, server v 5.6.16-log created 160510  9:26:03 at startup
# Warning: this binlog is either in use or was not closed properly.
ROLLBACK/*!*/;
# at 120
#160510  9:26:30 server id 4  end_log_pos 194 CRC32 0x4613aabe     Query    thread_id=1490    exec_time=0    error_code=0
SET TIMESTAMP=1462843590/*!*/;
SET @@session.pseudo_thread_id=1490/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
SET @@session.sql_mode=1075838976/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C utf8 *//*!*/;
SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=33/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
# at 194
#160510  9:26:30 server id 4  end_log_pos 245 CRC32 0x12aee719     Table_map: `testdb`.`t2` mapped to number 100
# at 245
#160510  9:26:30 server id 4  end_log_pos 292 CRC32 0x42bb4b1e     Delete_rows: table id 100 flags: STMT_END_F
### DELETE FROM `testdb`.`t2`
### WHERE
###   @1=2
###   @2='ch'
###   @3=0
# at 292
#160510  9:26:43 server id 4  end_log_pos 323 CRC32 0x7f4b17a2     Xid = 4683
COMMIT/*!*/;
# at 323
#160510  9:26:43 server id 4  end_log_pos 433 CRC32 0x3da26437     Query    thread_id=1490    exec_time=0    error_code=0
use `testdb`/*!*/;
SET TIMESTAMP=1462843603/*!*/;
alter table t2 drop column score
/*!*/;
# at 433
#160510  9:26:53 server id 4  end_log_pos 507 CRC32 0xaf228c7f     Query    thread_id=1490    exec_time=0    error_code=0
SET TIMESTAMP=1462843613/*!*/;
BEGIN
/*!*/;
# at 507
#160510  9:26:53 server id 4  end_log_pos 557 CRC32 0x98b09e6b     Table_map: `testdb`.`t2` mapped to number 108
# at 557
#160510  9:26:53 server id 4  end_log_pos 601 CRC32 0x56abcace     Delete_rows: table id 108 flags: STMT_END_F
### DELETE FROM `testdb`.`t2`
### WHERE
###   @1=3
###   @2='eng'
# at 601
#160510  9:26:53 server id 4  end_log_pos 632 CRC32 0x41e6e24f     Xid = 4754
COMMIT/*!*/;
# at 632
#160510  9:27:30 server id 4  end_log_pos 706 CRC32 0x4916f7a0     Query    thread_id=1490    exec_time=0    error_code=0
SET TIMESTAMP=1462843650/*!*/;
BEGIN
/*!*/;
# at 706
#160510  9:27:30 server id 4  end_log_pos 756 CRC32 0x15098e83     Table_map: `testdb`.`t2` mapped to number 108
# at 756
#160510  9:27:30 server id 4  end_log_pos 801 CRC32 0x2bc1b8aa     Delete_rows: table id 108 flags: STMT_END_F
### DELETE FROM `testdb`.`t2`
### WHERE
###   @1=1
###   @2='math'
# at 801
#160510  9:27:30 server id 4  end_log_pos 832 CRC32 0x9ce9b647     Xid = 4870
COMMIT/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
 
 
 
 

mysql一个事务中有DDL语句的binlog情况的更多相关文章

  1. 详解MySQL第一篇—MySQL简要介绍及DDL语句

    背景:近几年,开源数据库逐渐流行起来.由于具有免费使用.配置简单.稳定性好.性能优良等优点,开源数据库在中低端应用上占据了很大的市场份额,而 MySQL 正是开源数据库中的杰出代表.MySQL 数据库 ...

  2. mysql系列(2)之 DDL语句

    1.创建数据库test1:create database test1; 2.查询系统中都存在哪些数据库:show databases; 3.选择数据库:use test1; 4.查看数据库中所有的表: ...

  3. mysql中explain查看sql语句索引使用情况

    explain + sql: mysql> explain select * from user; +----+-------------+-------+------+------------ ...

  4. mysql transaction 事务

    1.事务简介 一个"最小的"不可再分的"工作单元". 一个事务通常对应了一个完整的业务.如:银行的转账功能,a转账给b,a扣钱,b加钱. 一个事务包含一条或多条 ...

  5. MySQL数据库事务各隔离级别加锁情况--read uncommitted篇(转)

    本文转自https://m.imooc.com/article/details?article_id=17291,感谢作者 1.目的 1.1 合适人群 1.数据库事务特征我只是背过,并没有很深刻的理解 ...

  6. MySQL中事务和事务的隔离级别

    本文主要是帮助理解相关知识,没有具体的操作和代码. 事务 事务就是一组操作,这组操作要么全部成功,要么全部失败. 最经典的例子就是银行转账: 张三给李四转账100,对用户来说,就是一个操作.但对应到数 ...

  7. MySQL(一):MySQL数据库事务与锁

    基本概念 事务是指满足ACID特性的的一组操作,可以通过Commit提交事务,也可以也可以通过Rollback进行回滚.会存在中间态和一致性状态(也是真正在数据库表中存在的状态) ACID Atomi ...

  8. oracle之 获取建表ddl语句

    第一种方法是使用工具,如:pl/sql developer,在[工具]--[导出用户对象]出现就可以得到建表脚本. 第二种方法是,sql语句. DBMS_METADATA.GET_DDL包可以得到数据 ...

  9. mysql中事务

    事务控制语言 什么叫做“事务”: 想象一个场景: 小明给小花 汇款 5000元 买 IPHONE,操作界面不用管,不管什么操作界面,最终都要落实到这样两条语句的执行: update  存款表  set ...

随机推荐

  1. WindowsPhone-GameBoy模拟器开发六--[转]指令系统实现必读:补码

    网上有同行写了些好文章,在此就不现丑了,贴上连接,放在这里为了补充系列的完整性 计算机为什么选用二进制补码 为什么补码重要?因为计算机中内存.寄存器里面存的数都是用补码表示的!

  2. 读取XML的问题

    利用SAX读取写了代码,调试了一下午却一直在parse里抛异常.尼玛,Java的库函数还真心不怎么好用. 把代码贴上来先: package com.example.gulanfinddemo; imp ...

  3. ReactiveCocoa与Functional Reactive Programming

    转自 http://blog.leezhong.com/ios/2013/06/19/frp-reactivecocoa.html Functional Reactive Programming(以下 ...

  4. context:annotation-config 与context:component-scan

    <context:annotation-config/> <context:component-scan base-package="com.xx" /> ...

  5. JavaScript 调试小技巧

    'debugger;' 除了console.log,debugger就是另一个我很喜欢的快速调试的工具,将debugger加入代码之后,Chrome会自动在插入它的地方停止,很像C或者Java里面打断 ...

  6. icmp,tcp,traceroute,ping,iptables

    有东莞的监控主机到北京BGP出问题了: 报警短信疯狂发送: 找东莞IDC和北京BGP服务商协查: 有个奇怪的问题:北京到东莞trcaceroute都有路由信息 东莞143段到北京全无路由信息:但,东莞 ...

  7. String和包装类Integer\Double\Long\Float\Character 都是final类型

    String和包装类Integer\Double\Long\Float\Character\Boolean 都是final类型 不可以改变

  8. ooofc.com域名备案问题导致无法正常访问临时解决方案

    各位尊敬的easyradius用户: 由于临时收到ooofc.coom域名备案被删除的消息,之后ooofc.com就无法访问.导致用户无法访问控制台oa.ooofc.com,及用户中心user.ooo ...

  9. 关于Unity程序在IOS和Android上显示内嵌网页的方式

    近期因为有须要在Unity程序执行在ios或android手机上显示内嵌网页.所以遍从网上搜集了一下相关的资料.整理例如以下: UnityWebCore 从搜索中先看到了这个.下载下来了以后发现这个的 ...

  10. Windows Live Writer配置步骤

    推荐文档: [超详细教程]使用Windows Live Writer 2012和Office Word 2013 发布文章到博客园全面总结 Live Writer 使用小贴示:发博客时始终使用图片原始 ...