mysql停止更新时间,MySQL – 当UPDATE命令被中断时会发生什么?

我通过My​​SQL命令行客户端发出了一个长时间运行的UPDATE查询(一个不正确的查询),并在几秒钟后用Ctrl-C将其停止.该命令尚未完成运行.我的数据库是否会针对某些条目进行更新,还是会在事务中发生并且所有内容都会回滚?

mysql>

^CCtrl-C -- sending "KILL QUERY 12088743" to server ...

Ctrl-C -- query aborted.

ERROR 1317 (70100): Query execution was interrupted

mysql>

更新:查询中涉及的所有表都是InnoDB表.

解决方法:

对于INNODB:Mysql手册说InnoDB(一个事务存储引擎)提供完整的ACID抱怨.因此,它将立即完成所有操作,或者在中断的情况下不执行操作和回滚.这是MySQL 5.5及以上版本的默认引擎.

MySQL includes components such as the InnoDB storage engine that adhere closely to the ACID model, so that data is not corrupted and results are not distorted by exceptional conditions such as software crashes and hardware malfunctions.

对于MYISAM:但对于非事务性的MyISAM存储引擎.这样的存储引擎遵循一种模型,其中数据一次写入一个语句.这是使用原子操作完成的.因此,如果您中断该过程,那么您将直到中断为止.

The nontransactional storage engines in MySQL Server (such as MyISAM) follow a different paradigm for data integrity called “atomic operations”. MyISAM tables effectively always operate in autocommit = 1 mode. Because changed data is written to disk one statement at a time, it is harder to guarantee the consistency of a sequence of related DML operations, which could be interrupted partway through. Thus, this mode is suitable for read-mostly workloads. In transactional terms, while each specific update is running, no other user can interfere with it, there can never be an automatic rollback, and there are no dirty reads.

但是,您可以使用LOCK TABLES作为解决方法.这是MySQL 5.5之前的默认存储引擎. *

所以答案取决于您使用的存储引擎.希望有帮助:)

标签:mysql,interrupt,sql-update,transactions

来源: https://codeday.me/bug/20190825/1720186.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值