mysql - 我如何知道我的表是事务表还是锁表?

标签 mysql sql triggers transactions

基于this questiondocumentation的这一段:

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/

相关文章:

php - 无效查询 : You have an error in your SQL syntax; syntax to use near

php - 我的 PHP 代码无法正常运行?

mysql - 全文 mysql 搜索不起作用

sql - 更改在 SQL 中选择的值

php - 数据表+服务器端处理=无法在多列中搜索

mysql - 从 SQL 表中选择每个唯一 ID 中的 3 个

mysql - 在表中添加第五个连接

swift - 从函数内触发按钮是否会在堆栈上留下一些东西?

oracle - 如何知道:new in a trigger?的类型

google-apps-script - 此上下文中出现异常 : Cannot call SpreadsheetApp. getUi()。 (第 2 行,文件 "Code")