如何显示刚刚发生的 MySQL 警告?
mysqlmysqli database
要显示 MySQL 警告,您可以使用以下语法 −
SHOW WARNINGS;
上述语法仅显示来自 MySQL 提示的即时警告。假设您在它们之间运行另一个查询,或者您丢失了 MySQL 连接,则 SHOW WARNINGS 将不起作用。
以下是显示警告的查询 −
mysql> SHOW WARNINGS;
以下是显示即时警告的输出 −
+-------+------+---------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Level | Code | Message | +-------+------+---------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Error | 1064 | You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'QUERY CACHE' at line 1 | +-------+------+---------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)