本文介绍了检查当前的FOREIGN_KEY_CHECKS值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何检查FOREIGN_KEY_CHECKS的当前值是什么?
How can I check what the current value of FOREIGN_KEY_CHECKS is?
我想确保该值为1.
推荐答案
检查 5.1.5服务器系统变量:: foreign_key_checks :
mysql> SELECT @@GLOBAL.foreign_key_checks, @@SESSION.foreign_key_checks;
+-----------------------------+------------------------------+
| @@GLOBAL.foreign_key_checks | @@SESSION.foreign_key_checks |
+-----------------------------+------------------------------+
| 1 | 1 |
+-----------------------------+------------------------------+
1 row in set (0.01 sec)
更新
mysql> SELECT VERSION();
+-----------+
| VERSION() |
+-----------+
| 5.7.18 |
+-----------+
1 row in set (0.00 sec)
mysql> SELECT IF((SELECT `VARIABLE_VALUE`
-> FROM `performance_schema`.`global_variables`
-> WHERE `VARIABLE_NAME` = 'foreign_key_checks') = 'ON', 1, 0) `global.foreign_key_checks`,
-> IF((SELECT `VARIABLE_VALUE`
-> FROM `performance_schema`.`session_variables`
-> WHERE `VARIABLE_NAME` = 'foreign_key_checks') = 'ON', 1, 0) `session.foreign_key_checks`;
+---------------------------+----------------------------+
| global.foreign_key_checks | session.foreign_key_checks |
+---------------------------+----------------------------+
| 1 | 1 |
+---------------------------+----------------------------+
1 row in set (0.00 sec)
这篇关于检查当前的FOREIGN_KEY_CHECKS值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!