Skip to content

Latest commit

 

History

History
83 lines (64 loc) · 2.1 KB

File metadata and controls

83 lines (64 loc) · 2.1 KB
title SHOW WARNINGS | TiDB SQL Statement Reference
summary TiDB データベースの SHOW WARNINGS の使用法の概要。

警告を表示 {#show-warnings}

このステートメントは、現在のクライアント接続で以前に実行されたステートメントで発生した警告のリストを表示します。MySQLと同様に、 sql_modeどのステートメントがエラーと警告を引き起こすかに大きな影響を与えます。

概要 {#synopsis}

ShowWarningsStmt ::=
    "SHOW" "WARNINGS"

例 {#examples}

mysql> CREATE TABLE t1 (a INT UNSIGNED);
Query OK, 0 rows affected (0.11 sec)

mysql> INSERT INTO t1 VALUES (0);
Query OK, 1 row affected (0.02 sec)

mysql> SELECT 1/a FROM t1;
+------+
| 1/a  |
+------+
| NULL |
+------+
1 row in set, 1 warning (0.00 sec)

mysql> SHOW WARNINGS;
+---------+------+---------------+
| Level   | Code | Message       |
+---------+------+---------------+
| Warning | 1365 | Division by 0 |
+---------+------+---------------+
1 row in set (0.00 sec)

mysql> INSERT INTO t1 VALUES (-1);
ERROR 1264 (22003): Out of range value for column 'a' at row 1
mysql> SELECT * FROM t1;
+------+
| a    |
+------+
|    0 |
+------+
1 row in set (0.00 sec)

mysql> SET sql_mode='';
Query OK, 0 rows affected (0.00 sec)

mysql> INSERT INTO t1 VALUES (-1);
Query OK, 1 row affected, 1 warning (0.01 sec)

mysql> SHOW WARNINGS;
+---------+------+---------------------------+
| Level   | Code | Message                   |
+---------+------+---------------------------+
| Warning | 1690 | constant -1 overflows int |
+---------+------+---------------------------+
1 row in set (0.00 sec)

mysql> SELECT * FROM t1;
+------+
| a    |
+------+
|    0 |
|    0 |
+------+
2 rows in set (0.00 sec)

MySQLの互換性 {#mysql-compatibility}

TiDBのSHOW WARNINGS文はMySQLと完全に互換性があります。互換性に違いがある場合は、 バグを報告する参照してください。

参照 {#see-also}