show errors 和 show warnings 显示执行语句所产生的错误、警告信息

本文将介绍 show errors 和 show warnings 显示执行语句所产生的错误、警告信息。

MySQL 的 show errors 命令可以显示执行语句所产生的错误信息,实例:

(1)执行 show errors 没有错误信息

mysql> show errors;
Empty set (0.00 sec)

(2)执行错误语句

mysql> show processlis;
ERROR 1064 (42000): 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 'processlis' at line 1
mysql> show table;
ERROR 1064 (42000): 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 '' at line 1

(3)再次执行 show errors 命令

mysql> show errors;
+-------+------+----------------------------------------------------------------------------------------------------------------------------------------------------+
| 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 '' at line 1 |
+-------+------+----------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

总结:show errors 命令将显示最后一次执行语句所产生的错误信息。

show errors 完整语法如下:

show errors [limit [offset,] row_count]

下面将演示 limit、offset 的用法。如下:

(1)我们故意执行多次错误语句,如下:

mysql> show processLis;
ERROR 1064 (42000): 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 'processLis' at line 1
mysql> show test;
ERROR 1064 (42000): 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 'test' at line 1
mysql> show statuss;
ERROR 1064 (42000): 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 'statuss' at line 1
mysql> show proces;
ERROR 1064 (42000): 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 'proces' at line 1

(2)使用 show errors list 显示错误信息

mysql> show errors limit 0,2;
+-------+------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| 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 'proces' at line 1 |
+-------+------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

结论:并没有显示多条错误消息,只显示了最后一条错误信息。

show warnings 完整语法如下:

show warnings [limit [offset,] row_count]

show warnings 显示最后一个执行语句所产生的警告信息,用法和 show errors 一致。

一寸光阴一寸金,寸金难买寸光阴。——《增广贤文》
0 不喜欢
说说我的看法 -
全部评论(
没有评论
关于
本网站属于个人的非赢利性网站,转载的文章遵循原作者的版权声明,如果原文没有版权声明,请来信告知:hxstrive@outlook.com
公众号