基于this question和documentation的这一段:
For transactional tables, failure of a statement should cause rollback of all changes performed by the statement. Failure of a trigger causes the statement to fail, so trigger failure also causes rollback. For nontransactional tables, such rollback cannot be done, so although the statement fails, any changes performed prior to the point of the error remain in effect.
我发现如果我的表是事务性的,那么查询和触发器将相互依赖。我的意思是查询和触发器要么都成功,要么都不成功。
那么我如何检测我的表是事务还是锁定?注意到我正在使用 MySQL、InnoDB 引擎和 PDO (如果了解这一点很重要)
最佳答案
您可以通过 SHOW CREATE TABLE
找到您正在使用的表类型,并查找 ENGINE
参数,或者使用 显示表状态
并查看Engine
列。
InnoDB 支持事务。 MyISAM(旧版 MySQL 引擎)则不然。
您还应该测试对您重要的任何系统的假设。仅仅因为您在本地使用特定引擎并不意味着它就是这样部署的,服务器默认值可能会有所不同。
关于mysql - 我如何知道我的表是事务表还是锁表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37752264/