我们可以知道最后一个MySQL错误吗?
为了知道最后的MySQL错误,您可以使用SHOW命令-
SHOW ERRORS;
或者您可以使用其他语法-
SHOW WARNINGS;
在这里,我们正在创建一个显示错误的表,然后我们将了解如何知道最后一个MySQL错误。在这里,发生错误是因为我们故意编写了不正确的create table语句-
mysql> create table DemoTable(Id int);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 'create table DemoTable(Id int)' at line 1
以下是知道最后一个MySQL错误的查询-
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 'create table DemoTable(Id int)' at line 1 |
+-------+------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
以上是 我们可以知道最后一个MySQL错误吗? 的全部内容, 来源链接: utcz.com/z/343540.html