在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. hdu - 4608 - I-number

    题意:给出一个正整数x,求最小的整数y,满足y > x且y的所有位的数字和是10的倍数.(x <= 100000) 题目链接:http://acm.hdu.edu.cn/showprobl ...

  2. 最新版ffmpeg源码分析

    最新版ffmpeg源码分析一:框架 (ffmpeg v0.9) 框架 最新版的ffmpeg中发现了一个新的东西:avconv,而且ffmpeg.c与avconv.c一个模样,一研究才发现是libav下 ...

  3. Activemq消息持久化

    官方文档: http://activemq.apache.org/persistence.html ActiveMq持久化相关配置:/usr/local/apache-activemq-5.11.1/ ...

  4. 巧用css border

    上下左右边框交界处呈现平滑的斜线.利用这个特点,通过设置不同的上下左右边框宽度或颜色,可以得到小三角.梯形等. 调整宽度大小可以调节三角形形状. 实现三角形 示例1: #test1{ height:2 ...

  5. easyui中 在子tabs中 添加新的tabs

    function addToParentTab(title, url) {            self.parent.addTabIgnoreExist(title, url, 'icon-cha ...

  6. IOS开发 应用程序图标数字角标

    其实实现这个功能很简单,只要调用UIApplication即可.   用法用例:[UIApplication sharedApplication].applicationIconBadgeNumber ...

  7. Delphi中设置条件断点

    写了这么长时间的代码,一直认为调试程序比写程序要重要,上次有人问俺,如何调试一个循环中某个循环条件位置下断点.本来想来在Delphi的断点设置中应该是有一个类似条件断点的东西的,不过我也一直不知道怎么 ...

  8. [Lua]50行代码的解释器,用来演示lambda calculus

    嗯,来写写经过: 在知乎上看见用Belleve牛用javascript写了一个精简的lisp解释器 => 我也想写一个,用lua写,能多简单呢? => 写了一个阉割的scheme解释器,包 ...

  9. Hive Streaming 追加 ORC 文件

    1.概述 在存储业务数据的时候,随着业务的增长,Hive 表存储在 HDFS 的上的数据会随时间的增加而增加,而以 Text 文本格式存储在 HDFS 上,所消耗的容量资源巨大.那么,我们需要有一种方 ...

  10. Java Web 工作技巧总结 16.10

    摘要: 原创出处:www.bysocket.com 泥瓦匠BYSocket 希望转载,保留摘要,谢谢! 在你成为领导者以前,成功只同自己的成长有关.当你成为领导者以后,成功都同别人的成长有关. 1.聊 ...