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 [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 [limit [offset,] row_count]
show warnings 显示最后一个执行语句所产生的警告信息,用法和 show errors 一致。