5.6之后新特性

探讨MySQL 5.6及以后版本中,当binlog格式设置为statement时,使用insert...select语句可能带来的不安全性。特别是由于插入操作依赖于检索行的顺序,这在主从复制场景下可能导致不一致。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 在5.6之后版本中,如果binlog格式设置为statement 。那么 insert  .....select .....语句将是不安全。如下报警信息

 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statements writing to a table with an auto-increment column after selecting from another table are unsafe because the order in which rows are retrieved determines what (if any) rows will be written. This order cannot be predicted and may differ on master and the slave.

 不安全主要是因为 insert ......select ......操作原理,其中用到了临时表。



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值