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 - 图1

ShowLikeOrWhere

SHOW ERRORS - 图2

  1. ShowErrorsStmt ::=
  2. "SHOW" "ERRORS" ShowLikeOrWhere?
  3. ShowLikeOrWhere ::=
  4. "LIKE" SimpleExpr
  5. | "WHERE" Expression

Examples

  1. mysql> select invalid;
  2. ERROR 1054 (42S22): Unknown column 'invalid' in 'field list'
  3. mysql> create invalid;
  4. 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"
  5. mysql> SHOW ERRORS;
  6. +-------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+
  7. | Level | Code | Message |
  8. +-------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+
  9. | Error | 1054 | Unknown column 'invalid' in 'field list' |
  10. | 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" |
  11. +-------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+
  12. 2 rows in set (0.00 sec)
  13. mysql> CREATE invalid2;
  14. 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"
  15. mysql> SELECT 1;
  16. +------+
  17. | 1 |
  18. +------+
  19. | 1 |
  20. +------+
  21. 1 row in set (0.00 sec)
  22. mysql> SHOW ERRORS;
  23. 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