Skip to content

Latest commit

 

History

History
60 lines (46 loc) · 2.65 KB

sql-statement-show-errors.md

File metadata and controls

60 lines (46 loc) · 2.65 KB
title summary aliases
SHOW ERRORS | TiDB SQL Statement Reference
An overview of the usage of SHOW ERRORS for the TiDB database.
/docs/dev/sql-statements/sql-statement-show-errors/
/docs/dev/reference/sql/statements/show-errors/

SHOW ERRORS

This statement shows errors from previously executed statements. The error buffer is cleared as soon as a statement executes successfully. In which case, SHOW ERRORS will return an empty set.

The behavior of which statements generate errors vs. warnings is highly influenced by the current sql_mode.

Synopsis

ShowErrorsStmt ::=
    "SHOW" "ERRORS" ShowLikeOrWhere?

ShowLikeOrWhere ::=
    "LIKE" SimpleExpr
|   "WHERE" Expression

Examples

mysql> select invalid;
ERROR 1054 (42S22): Unknown column 'invalid' in 'field list'
mysql> create invalid;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use line 1 column 14 near "invalid"
mysql> SHOW ERRORS;
+-------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+
| Level | Code | Message                                                                                                                                                   |
+-------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+
| Error | 1054 | Unknown column 'invalid' in 'field list'                                                                                                                  |
| Error | 1064 | You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use line 1 column 14 near "invalid"  |
+-------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

mysql> CREATE invalid2;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use line 1 column 15 near "invalid2"
mysql> SELECT 1;
+------+
| 1    |
+------+
|    1 |
+------+
1 row in set (0.00 sec)

mysql> SHOW ERRORS;
Empty set (0.00 sec)

MySQL compatibility

The SHOW ERRORS statement in TiDB is fully compatible with MySQL. If you find any compatibility differences, report a bug.

See also