在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. java/.net-常用工具下载地址&常用学习网址&快捷键

    HTML5 HTML5:http://www.html5cn.org/ php常用网址 thinkphp框架:http://www.thinkphp.cn/ wampserver开发服务器:http: ...

  2. java项目中读取properties文件

    这里的配置文件都放在src下面, System.properties的内容 exceptionMapping=exceptionMapping.properties config=config.pro ...

  3. 从Tmux 转到GNU Screen

    网上很多地方都说Tmux比GNU Screen要好用,不过无意间看到这篇Switching from tmux to GNU Screen之后,我发现GNU Screen的窗口/区域概念更好,至少是更 ...

  4. Struts2返回json

    Action怎么返回json类型数据?方法1,使用struts2的插件struts2-json-plugin-2.3.8.jar(在下载的strut2库文件夹中). 在struts2.xml中对要返回 ...

  5. Apache+PHP+Mysql 集成环境 几个软件pk

    WampServer 2.5 64位 - 工具软件 - 源码之家 2014年8月25日 - WampServer是Apache+PHP+Mysql 集成环境,拥有简单的图形和菜单安装和配置环境.支持2 ...

  6. 在Unity3D的网络游戏中实现资源动态加载

    用Unity3D制作基于web的网络游戏,不可避免的会用到一个技术-资源动态加载.比如想加载一个大场景的资源,不应该在游戏的开始让用户长时间等待全部资源的加载完毕.应该优先加载用户附近的场景资源,在游 ...

  7. 如何将 Cortana 与 Windows Phone 8.1 应用集成 ( Voice command - Natural language recognition )

    随着 Windows Phone 8.1 GDR1 + Cortana 中文版的发布,相信有很多用户或开发者都在调戏 Windows Phone 的语音私人助理 Cortana 吧,在世界杯的时候我亲 ...

  8. WCF中因序列化问题引起的异常和错误。

    尝试对参数 http://tempuri.org/ 进行序列化时出错: parameters.InnerException 消息是“不应为数据协定名称为“DBNull:http://schemas.d ...

  9. 【Android】Handler、Looper源码分析

    一.前言 源码分析使用的版本是 4.4.2_r1. Handler和Looper的入门知识以及讲解可以参考我的另外一篇博客:Android Handler机制 简单而言:Handler和Looper是 ...

  10. [LeetCode] Pow(x, n) 二分搜索

    Implement pow(x, n). Hide Tags Math Binary Search     题目很简单的.   class Solution { public: double pow( ...