• SHOW WARNINGS
    • 语法图
    • 示例
    • MySQL 兼容性
    • 另请参阅

    SHOW WARNINGS

    SHOW WARNINGS 语句用于显示当前客户端连接中已执行语句的报错列表。与在 MySQL 中一样,sql_mode 极大地影响哪些语句会导致错误与警告。

    语法图

    ShowStmt:

    ShowStmt

    ShowTargetFilterable:

    ShowTargetFilterable

    示例

    1. mysql> CREATE TABLE t1 (a INT UNSIGNED);
    2. Query OK, 0 rows affected (0.11 sec)
    3. mysql> INSERT INTO t1 VALUES (0);
    4. Query OK, 1 row affected (0.02 sec)
    5. mysql> SELECT 1/a FROM t1;
    6. +------+
    7. | 1/a |
    8. +------+
    9. | NULL |
    10. +------+
    11. 1 row in set, 1 warning (0.00 sec)
    12. mysql> SHOW WARNINGS;
    13. +---------+------+---------------+
    14. | Level | Code | Message |
    15. +---------+------+---------------+
    16. | Warning | 1365 | Division by 0 |
    17. +---------+------+---------------+
    18. 1 row in set (0.00 sec)
    19. mysql> INSERT INTO t1 VALUES (-1);
    20. ERROR 1264 (22003): Out of range value for column 'a' at row 1
    21. mysql> SELECT * FROM t1;
    22. +------+
    23. | a |
    24. +------+
    25. | 0 |
    26. +------+
    27. 1 row in set (0.00 sec)
    28. mysql> SET sql_mode='';
    29. Query OK, 0 rows affected (0.00 sec)
    30. mysql> INSERT INTO t1 VALUES (-1);
    31. Query OK, 1 row affected, 1 warning (0.01 sec)
    32. mysql> SHOW WARNINGS;
    33. +---------+------+---------------------------+
    34. | Level | Code | Message |
    35. +---------+------+---------------------------+
    36. | Warning | 1690 | constant -1 overflows int |
    37. +---------+------+---------------------------+
    38. 1 row in set (0.00 sec)
    39. mysql> SELECT * FROM t1;
    40. +------+
    41. | a |
    42. +------+
    43. | 0 |
    44. | 0 |
    45. +------+
    46. 2 rows in set (0.00 sec)

    MySQL 兼容性

    SHOW WARNINGS 语句与 MySQL 完全兼容。如有任何兼容性差异,请在 GitHub 上提交 issue。

    另请参阅

    • SHOW ERRORS