13.7.7.42 & NBSP; Hiển thị tuyên bố cảnh báo
SHOW WARNINGS [LIMIT [offset,] row_count]
SHOW COUNT[*] WARNINGS
SHOW WARNINGS
là một tuyên bố chẩn đoán hiển thị thông tin về các điều kiện [lỗi, cảnh báo và ghi chú] do thực hiện một tuyên bố trong phiên hiện tại. Các cảnh báo được tạo ra cho các câu lệnh DML như INSERT
, UPDATE
và LOAD DATA
cũng như các câu lệnh DDL như
SHOW COUNT[*] WARNINGS;
SELECT @@warning_count;
0 và SHOW COUNT[*] WARNINGS;
SELECT @@warning_count;
1.Điều khoản
SHOW COUNT[*] WARNINGS;
SELECT @@warning_count;
2 có cùng cú pháp với câu lệnh SHOW COUNT[*] WARNINGS;
SELECT @@warning_count;
3. Xem Phần & NBSP; 13.2.10, Câu lệnh Chọn. SHOW WARNINGS
cũng được sử dụng sau
SHOW COUNT[*] WARNINGS;
SELECT @@warning_count;
5, để hiển thị thông tin mở rộng được tạo bởi SHOW COUNT[*] WARNINGS;
SELECT @@warning_count;
5. Xem Phần & NBSP; 8.8.3, Định dạng đầu ra mở rộng giải thích. SHOW WARNINGS
hiển thị thông tin về các điều kiện do thực hiện tuyên bố không chẩn đoán gần đây nhất trong phiên hiện tại. Nếu câu lệnh gần đây nhất dẫn đến lỗi trong quá trình phân tích cú pháp, SHOW WARNINGS
cho thấy các điều kiện kết quả, bất kể loại tuyên bố [chẩn đoán hoặc không chẩn đoán].
Câu lệnh chẩn đoán
SHOW COUNT[*] WARNINGS;
SELECT @@warning_count;
9 hiển thị tổng số lỗi, cảnh báo và ghi chú. Bạn cũng có thể truy xuất số này từ biến hệ thống mysql> CREATE TABLE t1 [a TINYINT NOT NULL, b CHAR[4]];
Query OK, 0 rows affected [0.05 sec]
mysql> INSERT INTO t1 VALUES[10,'mysql'], [NULL,'test'], [300,'xyz'];
Query OK, 3 rows affected, 3 warnings [0.00 sec]
Records: 3 Duplicates: 0 Warnings: 3
mysql> SHOW WARNINGS\G
*************************** 1. row ***************************
Level: Warning
Code: 1265
Message: Data truncated for column 'b' at row 1
*************************** 2. row ***************************
Level: Warning
Code: 1048
Message: Column 'a' cannot be null
*************************** 3. row ***************************
Level: Warning
Code: 1264
Message: Out of range value for column 'a' at row 3
3 rows in set [0.00 sec]
0:SHOW COUNT[*] WARNINGS;
SELECT @@warning_count;
Một sự khác biệt trong các tuyên bố này là câu nói đầu tiên là một tuyên bố chẩn đoán không xóa danh sách tin nhắn. Thứ hai, bởi vì đó là một tuyên bố
SHOW COUNT[*] WARNINGS;
SELECT @@warning_count;
3 được coi là không chẩn đoán và làm rõ danh sách tin nhắn.Một tuyên bố chẩn đoán liên quan,
mysql> CREATE TABLE t1 [a TINYINT NOT NULL, b CHAR[4]];
Query OK, 0 rows affected [0.05 sec]
mysql> INSERT INTO t1 VALUES[10,'mysql'], [NULL,'test'], [300,'xyz'];
Query OK, 3 rows affected, 3 warnings [0.00 sec]
Records: 3 Duplicates: 0 Warnings: 3
mysql> SHOW WARNINGS\G
*************************** 1. row ***************************
Level: Warning
Code: 1265
Message: Data truncated for column 'b' at row 1
*************************** 2. row ***************************
Level: Warning
Code: 1048
Message: Column 'a' cannot be null
*************************** 3. row ***************************
Level: Warning
Code: 1264
Message: Out of range value for column 'a' at row 3
3 rows in set [0.00 sec]
2, chỉ hiển thị các điều kiện lỗi [nó không bao gồm các cảnh báo và ghi chú] và câu lệnh mysql> CREATE TABLE t1 [a TINYINT NOT NULL, b CHAR[4]];
Query OK, 0 rows affected [0.05 sec]
mysql> INSERT INTO t1 VALUES[10,'mysql'], [NULL,'test'], [300,'xyz'];
Query OK, 3 rows affected, 3 warnings [0.00 sec]
Records: 3 Duplicates: 0 Warnings: 3
mysql> SHOW WARNINGS\G
*************************** 1. row ***************************
Level: Warning
Code: 1265
Message: Data truncated for column 'b' at row 1
*************************** 2. row ***************************
Level: Warning
Code: 1048
Message: Column 'a' cannot be null
*************************** 3. row ***************************
Level: Warning
Code: 1264
Message: Out of range value for column 'a' at row 3
3 rows in set [0.00 sec]
3 hiển thị tổng số lỗi. Xem Phần & NBSP; 13.7.7.17, Trình hiển thị lỗi Báo cáo lỗi. mysql> CREATE TABLE t1 [a TINYINT NOT NULL, b CHAR[4]];
Query OK, 0 rows affected [0.05 sec]
mysql> INSERT INTO t1 VALUES[10,'mysql'], [NULL,'test'], [300,'xyz'];
Query OK, 3 rows affected, 3 warnings [0.00 sec]
Records: 3 Duplicates: 0 Warnings: 3
mysql> SHOW WARNINGS\G
*************************** 1. row ***************************
Level: Warning
Code: 1265
Message: Data truncated for column 'b' at row 1
*************************** 2. row ***************************
Level: Warning
Code: 1048
Message: Column 'a' cannot be null
*************************** 3. row ***************************
Level: Warning
Code: 1264
Message: Out of range value for column 'a' at row 3
3 rows in set [0.00 sec]
4 có thể được sử dụng để kiểm tra thông tin cho các điều kiện riêng lẻ. Xem Phần & NBSP; 13.6.7.3, Nhận được tuyên bố chẩn đoán. Dưới đây là một ví dụ đơn giản hiển thị các cảnh báo chuyển đổi dữ liệu cho INSERT
. Ví dụ giả định rằng chế độ SQL nghiêm ngặt bị vô hiệu hóa. Với chế độ nghiêm ngặt được bật, các cảnh báo sẽ trở thành lỗi và chấm dứt INSERT
.
mysql> CREATE TABLE t1 [a TINYINT NOT NULL, b CHAR[4]];
Query OK, 0 rows affected [0.05 sec]
mysql> INSERT INTO t1 VALUES[10,'mysql'], [NULL,'test'], [300,'xyz'];
Query OK, 3 rows affected, 3 warnings [0.00 sec]
Records: 3 Duplicates: 0 Warnings: 3
mysql> SHOW WARNINGS\G
*************************** 1. row ***************************
Level: Warning
Code: 1265
Message: Data truncated for column 'b' at row 1
*************************** 2. row ***************************
Level: Warning
Code: 1048
Message: Column 'a' cannot be null
*************************** 3. row ***************************
Level: Warning
Code: 1264
Message: Out of range value for column 'a' at row 3
3 rows in set [0.00 sec]
Biến hệ thống
mysql> CREATE TABLE t1 [a TINYINT NOT NULL, b CHAR[4]];
Query OK, 0 rows affected [0.05 sec]
mysql> INSERT INTO t1 VALUES[10,'mysql'], [NULL,'test'], [300,'xyz'];
Query OK, 3 rows affected, 3 warnings [0.00 sec]
Records: 3 Duplicates: 0 Warnings: 3
mysql> SHOW WARNINGS\G
*************************** 1. row ***************************
Level: Warning
Code: 1265
Message: Data truncated for column 'b' at row 1
*************************** 2. row ***************************
Level: Warning
Code: 1048
Message: Column 'a' cannot be null
*************************** 3. row ***************************
Level: Warning
Code: 1264
Message: Out of range value for column 'a' at row 3
3 rows in set [0.00 sec]
7 kiểm soát số lượng lỗi, cảnh báo và ghi chú tối đa tối đa mà máy chủ lưu trữ thông tin và do đó số lượng tin nhắn mà mysql> CREATE TABLE t1 [a TINYINT NOT NULL, b CHAR[4]];
Query OK, 0 rows affected [0.05 sec]
mysql> INSERT INTO t1 VALUES[10,'mysql'], [NULL,'test'], [300,'xyz'];
Query OK, 3 rows affected, 3 warnings [0.00 sec]
Records: 3 Duplicates: 0 Warnings: 3
mysql> SHOW WARNINGS\G
*************************** 1. row ***************************
Level: Warning
Code: 1265
Message: Data truncated for column 'b' at row 1
*************************** 2. row ***************************
Level: Warning
Code: 1048
Message: Column 'a' cannot be null
*************************** 3. row ***************************
Level: Warning
Code: 1264
Message: Out of range value for column 'a' at row 3
3 rows in set [0.00 sec]
8 hiển thị. Để thay đổi số lượng tin nhắn mà máy chủ có thể lưu trữ, hãy thay đổi giá trị của mysql> CREATE TABLE t1 [a TINYINT NOT NULL, b CHAR[4]];
Query OK, 0 rows affected [0.05 sec]
mysql> INSERT INTO t1 VALUES[10,'mysql'], [NULL,'test'], [300,'xyz'];
Query OK, 3 rows affected, 3 warnings [0.00 sec]
Records: 3 Duplicates: 0 Warnings: 3
mysql> SHOW WARNINGS\G
*************************** 1. row ***************************
Level: Warning
Code: 1265
Message: Data truncated for column 'b' at row 1
*************************** 2. row ***************************
Level: Warning
Code: 1048
Message: Column 'a' cannot be null
*************************** 3. row ***************************
Level: Warning
Code: 1264
Message: Out of range value for column 'a' at row 3
3 rows in set [0.00 sec]
7.
mysql> CREATE TABLE t1 [a TINYINT NOT NULL, b CHAR[4]];
Query OK, 0 rows affected [0.05 sec]
mysql> INSERT INTO t1 VALUES[10,'mysql'], [NULL,'test'], [300,'xyz'];
Query OK, 3 rows affected, 3 warnings [0.00 sec]
Records: 3 Duplicates: 0 Warnings: 3
mysql> SHOW WARNINGS\G
*************************** 1. row ***************************
Level: Warning
Code: 1265
Message: Data truncated for column 'b' at row 1
*************************** 2. row ***************************
Level: Warning
Code: 1048
Message: Column 'a' cannot be null
*************************** 3. row ***************************
Level: Warning
Code: 1264
Message: Out of range value for column 'a' at row 3
3 rows in set [0.00 sec]
7 Chỉ kiểm soát số lượng tin nhắn được lưu trữ, không phải số lượng được tính. Giá trị của mysql> CREATE TABLE t1 [a TINYINT NOT NULL, b CHAR[4]];
Query OK, 0 rows affected [0.05 sec]
mysql> INSERT INTO t1 VALUES[10,'mysql'], [NULL,'test'], [300,'xyz'];
Query OK, 3 rows affected, 3 warnings [0.00 sec]
Records: 3 Duplicates: 0 Warnings: 3
mysql> SHOW WARNINGS\G
*************************** 1. row ***************************
Level: Warning
Code: 1265
Message: Data truncated for column 'b' at row 1
*************************** 2. row ***************************
Level: Warning
Code: 1048
Message: Column 'a' cannot be null
*************************** 3. row ***************************
Level: Warning
Code: 1264
Message: Out of range value for column 'a' at row 3
3 rows in set [0.00 sec]
0 không bị giới hạn bởi mysql> CREATE TABLE t1 [a TINYINT NOT NULL, b CHAR[4]];
Query OK, 0 rows affected [0.05 sec]
mysql> INSERT INTO t1 VALUES[10,'mysql'], [NULL,'test'], [300,'xyz'];
Query OK, 3 rows affected, 3 warnings [0.00 sec]
Records: 3 Duplicates: 0 Warnings: 3
mysql> SHOW WARNINGS\G
*************************** 1. row ***************************
Level: Warning
Code: 1265
Message: Data truncated for column 'b' at row 1
*************************** 2. row ***************************
Level: Warning
Code: 1048
Message: Column 'a' cannot be null
*************************** 3. row ***************************
Level: Warning
Code: 1264
Message: Out of range value for column 'a' at row 3
3 rows in set [0.00 sec]
7, ngay cả khi số lượng tin nhắn được tạo vượt quá mysql> CREATE TABLE t1 [a TINYINT NOT NULL, b CHAR[4]];
Query OK, 0 rows affected [0.05 sec]
mysql> INSERT INTO t1 VALUES[10,'mysql'], [NULL,'test'], [300,'xyz'];
Query OK, 3 rows affected, 3 warnings [0.00 sec]
Records: 3 Duplicates: 0 Warnings: 3
mysql> SHOW WARNINGS\G
*************************** 1. row ***************************
Level: Warning
Code: 1265
Message: Data truncated for column 'b' at row 1
*************************** 2. row ***************************
Level: Warning
Code: 1048
Message: Column 'a' cannot be null
*************************** 3. row ***************************
Level: Warning
Code: 1264
Message: Out of range value for column 'a' at row 3
3 rows in set [0.00 sec]
7. Ví dụ sau đây chứng minh điều này. Tuyên bố mysql> SHOW VARIABLES LIKE 'max_error_count';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_error_count | 1024 |
+-----------------+-------+
1 row in set [0.00 sec]
mysql> SET max_error_count=1, sql_mode = '';
Query OK, 0 rows affected [0.00 sec]
mysql> ALTER TABLE t1 MODIFY b CHAR;
Query OK, 3 rows affected, 3 warnings [0.00 sec]
Records: 3 Duplicates: 0 Warnings: 3
mysql> SHOW WARNINGS;
+---------+------+----------------------------------------+
| Level | Code | Message |
+---------+------+----------------------------------------+
| Warning | 1263 | Data truncated for column 'b' at row 1 |
+---------+------+----------------------------------------+
1 row in set [0.00 sec]
mysql> SELECT @@warning_count;
+-----------------+
| @@warning_count |
+-----------------+
| 3 |
+-----------------+
1 row in set [0.01 sec]
4 tạo ra ba thông báo cảnh báo [chế độ SQL nghiêm ngặt bị vô hiệu hóa trong ví dụ để ngăn lỗi xảy ra sau một vấn đề chuyển đổi duy nhất]. Chỉ có một thông báo được lưu trữ và hiển thị vì mysql> CREATE TABLE t1 [a TINYINT NOT NULL, b CHAR[4]];
Query OK, 0 rows affected [0.05 sec]
mysql> INSERT INTO t1 VALUES[10,'mysql'], [NULL,'test'], [300,'xyz'];
Query OK, 3 rows affected, 3 warnings [0.00 sec]
Records: 3 Duplicates: 0 Warnings: 3
mysql> SHOW WARNINGS\G
*************************** 1. row ***************************
Level: Warning
Code: 1265
Message: Data truncated for column 'b' at row 1
*************************** 2. row ***************************
Level: Warning
Code: 1048
Message: Column 'a' cannot be null
*************************** 3. row ***************************
Level: Warning
Code: 1264
Message: Out of range value for column 'a' at row 3
3 rows in set [0.00 sec]
7 đã được đặt thành 1, nhưng cả ba tin nhắn đều được tính [như được hiển thị bởi giá trị của mysql> CREATE TABLE t1 [a TINYINT NOT NULL, b CHAR[4]];
Query OK, 0 rows affected [0.05 sec]
mysql> INSERT INTO t1 VALUES[10,'mysql'], [NULL,'test'], [300,'xyz'];
Query OK, 3 rows affected, 3 warnings [0.00 sec]
Records: 3 Duplicates: 0 Warnings: 3
mysql> SHOW WARNINGS\G
*************************** 1. row ***************************
Level: Warning
Code: 1265
Message: Data truncated for column 'b' at row 1
*************************** 2. row ***************************
Level: Warning
Code: 1048
Message: Column 'a' cannot be null
*************************** 3. row ***************************
Level: Warning
Code: 1264
Message: Out of range value for column 'a' at row 3
3 rows in set [0.00 sec]
0]:mysql> SHOW VARIABLES LIKE 'max_error_count';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_error_count | 1024 |
+-----------------+-------+
1 row in set [0.00 sec]
mysql> SET max_error_count=1, sql_mode = '';
Query OK, 0 rows affected [0.00 sec]
mysql> ALTER TABLE t1 MODIFY b CHAR;
Query OK, 3 rows affected, 3 warnings [0.00 sec]
Records: 3 Duplicates: 0 Warnings: 3
mysql> SHOW WARNINGS;
+---------+------+----------------------------------------+
| Level | Code | Message |
+---------+------+----------------------------------------+
| Warning | 1263 | Data truncated for column 'b' at row 1 |
+---------+------+----------------------------------------+
1 row in set [0.00 sec]
mysql> SELECT @@warning_count;
+-----------------+
| @@warning_count |
+-----------------+
| 3 |
+-----------------+
1 row in set [0.01 sec]
Để vô hiệu hóa lưu trữ tin nhắn, đặt
mysql> CREATE TABLE t1 [a TINYINT NOT NULL, b CHAR[4]];
Query OK, 0 rows affected [0.05 sec]
mysql> INSERT INTO t1 VALUES[10,'mysql'], [NULL,'test'], [300,'xyz'];
Query OK, 3 rows affected, 3 warnings [0.00 sec]
Records: 3 Duplicates: 0 Warnings: 3
mysql> SHOW WARNINGS\G
*************************** 1. row ***************************
Level: Warning
Code: 1265
Message: Data truncated for column 'b' at row 1
*************************** 2. row ***************************
Level: Warning
Code: 1048
Message: Column 'a' cannot be null
*************************** 3. row ***************************
Level: Warning
Code: 1264
Message: Out of range value for column 'a' at row 3
3 rows in set [0.00 sec]
7 thành 0. Trong trường hợp này, mysql> CREATE TABLE t1 [a TINYINT NOT NULL, b CHAR[4]];
Query OK, 0 rows affected [0.05 sec]
mysql> INSERT INTO t1 VALUES[10,'mysql'], [NULL,'test'], [300,'xyz'];
Query OK, 3 rows affected, 3 warnings [0.00 sec]
Records: 3 Duplicates: 0 Warnings: 3
mysql> SHOW WARNINGS\G
*************************** 1. row ***************************
Level: Warning
Code: 1265
Message: Data truncated for column 'b' at row 1
*************************** 2. row ***************************
Level: Warning
Code: 1048
Message: Column 'a' cannot be null
*************************** 3. row ***************************
Level: Warning
Code: 1264
Message: Out of range value for column 'a' at row 3
3 rows in set [0.00 sec]
0 vẫn cho biết có bao nhiêu cảnh báo xảy ra, nhưng tin nhắn không được lưu trữ và không thể được hiển thị.Biến hệ thống
mysql> SHOW VARIABLES LIKE 'max_error_count';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_error_count | 1024 |
+-----------------+-------+
1 row in set [0.00 sec]
mysql> SET max_error_count=1, sql_mode = '';
Query OK, 0 rows affected [0.00 sec]
mysql> ALTER TABLE t1 MODIFY b CHAR;
Query OK, 3 rows affected, 3 warnings [0.00 sec]
Records: 3 Duplicates: 0 Warnings: 3
mysql> SHOW WARNINGS;
+---------+------+----------------------------------------+
| Level | Code | Message |
+---------+------+----------------------------------------+
| Warning | 1263 | Data truncated for column 'b' at row 1 |
+---------+------+----------------------------------------+
1 row in set [0.00 sec]
mysql> SELECT @@warning_count;
+-----------------+
| @@warning_count |
+-----------------+
| 3 |
+-----------------+
1 row in set [0.01 sec]
9 có kiểm soát xem thông báo ghi chú có tăng hay không và liệu máy chủ có lưu trữ chúng không. Theo mặc định, mysql> SHOW VARIABLES LIKE 'max_error_count';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_error_count | 1024 |
+-----------------+-------+
1 row in set [0.00 sec]
mysql> SET max_error_count=1, sql_mode = '';
Query OK, 0 rows affected [0.00 sec]
mysql> ALTER TABLE t1 MODIFY b CHAR;
Query OK, 3 rows affected, 3 warnings [0.00 sec]
Records: 3 Duplicates: 0 Warnings: 3
mysql> SHOW WARNINGS;
+---------+------+----------------------------------------+
| Level | Code | Message |
+---------+------+----------------------------------------+
| Warning | 1263 | Data truncated for column 'b' at row 1 |
+---------+------+----------------------------------------+
1 row in set [0.00 sec]
mysql> SELECT @@warning_count;
+-----------------+
| @@warning_count |
+-----------------+
| 3 |
+-----------------+
1 row in set [0.01 sec]
9 là 1, nhưng nếu được đặt thành 0, các ghi chú không tăng mysql> CREATE TABLE t1 [a TINYINT NOT NULL, b CHAR[4]];
Query OK, 0 rows affected [0.05 sec]
mysql> INSERT INTO t1 VALUES[10,'mysql'], [NULL,'test'], [300,'xyz'];
Query OK, 3 rows affected, 3 warnings [0.00 sec]
Records: 3 Duplicates: 0 Warnings: 3
mysql> SHOW WARNINGS\G
*************************** 1. row ***************************
Level: Warning
Code: 1265
Message: Data truncated for column 'b' at row 1
*************************** 2. row ***************************
Level: Warning
Code: 1048
Message: Column 'a' cannot be null
*************************** 3. row ***************************
Level: Warning
Code: 1264
Message: Out of range value for column 'a' at row 3
3 rows in set [0.00 sec]
0 và máy chủ không lưu trữ chúng:mysql> SET sql_notes = 1;
mysql> DROP TABLE IF EXISTS test.no_such_table;
Query OK, 0 rows affected, 1 warning [0.00 sec]
mysql> SHOW WARNINGS;
+-------+------+------------------------------------+
| Level | Code | Message |
+-------+------+------------------------------------+
| Note | 1051 | Unknown table 'test.no_such_table' |
+-------+------+------------------------------------+
1 row in set [0.00 sec]
mysql> SET sql_notes = 0;
mysql> DROP TABLE IF EXISTS test.no_such_table;
Query OK, 0 rows affected [0.00 sec]
mysql> SHOW WARNINGS;
Empty set [0.00 sec]
Máy chủ MySQL gửi cho mỗi máy khách một số cho biết tổng số lỗi, cảnh báo và ghi chú do câu lệnh gần đây nhất được thực hiện bởi máy khách đó. Từ API C, giá trị này có thể thu được bằng cách gọi
mysql> SET sql_notes = 1;
mysql> DROP TABLE IF EXISTS test.no_such_table;
Query OK, 0 rows affected, 1 warning [0.00 sec]
mysql> SHOW WARNINGS;
+-------+------+------------------------------------+
| Level | Code | Message |
+-------+------+------------------------------------+
| Note | 1051 | Unknown table 'test.no_such_table' |
+-------+------+------------------------------------+
1 row in set [0.00 sec]
mysql> SET sql_notes = 0;
mysql> DROP TABLE IF EXISTS test.no_such_table;
Query OK, 0 rows affected [0.00 sec]
mysql> SHOW WARNINGS;
Empty set [0.00 sec]
3. Xem mysql_warning_count [].Trong ứng dụng khách MySQL, bạn có thể bật và tắt hiển thị cảnh báo tự động bằng các lệnh
mysql> SET sql_notes = 1;
mysql> DROP TABLE IF EXISTS test.no_such_table;
Query OK, 0 rows affected, 1 warning [0.00 sec]
mysql> SHOW WARNINGS;
+-------+------+------------------------------------+
| Level | Code | Message |
+-------+------+------------------------------------+
| Note | 1051 | Unknown table 'test.no_such_table' |
+-------+------+------------------------------------+
1 row in set [0.00 sec]
mysql> SET sql_notes = 0;
mysql> DROP TABLE IF EXISTS test.no_such_table;
Query OK, 0 rows affected [0.00 sec]
mysql> SHOW WARNINGS;
Empty set [0.00 sec]
4 và mysql> SET sql_notes = 1;
mysql> DROP TABLE IF EXISTS test.no_such_table;
Query OK, 0 rows affected, 1 warning [0.00 sec]
mysql> SHOW WARNINGS;
+-------+------+------------------------------------+
| Level | Code | Message |
+-------+------+------------------------------------+
| Note | 1051 | Unknown table 'test.no_such_table' |
+-------+------+------------------------------------+
1 row in set [0.00 sec]
mysql> SET sql_notes = 0;
mysql> DROP TABLE IF EXISTS test.no_such_table;
Query OK, 0 rows affected [0.00 sec]
mysql> SHOW WARNINGS;
Empty set [0.00 sec]
5, hoặc các phím tắt của chúng, mysql> SET sql_notes = 1;
mysql> DROP TABLE IF EXISTS test.no_such_table;
Query OK, 0 rows affected, 1 warning [0.00 sec]
mysql> SHOW WARNINGS;
+-------+------+------------------------------------+
| Level | Code | Message |
+-------+------+------------------------------------+
| Note | 1051 | Unknown table 'test.no_such_table' |
+-------+------+------------------------------------+
1 row in set [0.00 sec]
mysql> SET sql_notes = 0;
mysql> DROP TABLE IF EXISTS test.no_such_table;
Query OK, 0 rows affected [0.00 sec]
mysql> SHOW WARNINGS;
Empty set [0.00 sec]
6 và mysql> SET sql_notes = 1;
mysql> DROP TABLE IF EXISTS test.no_such_table;
Query OK, 0 rows affected, 1 warning [0.00 sec]
mysql> SHOW WARNINGS;
+-------+------+------------------------------------+
| Level | Code | Message |
+-------+------+------------------------------------+
| Note | 1051 | Unknown table 'test.no_such_table' |
+-------+------+------------------------------------+
1 row in set [0.00 sec]
mysql> SET sql_notes = 0;
mysql> DROP TABLE IF EXISTS test.no_such_table;
Query OK, 0 rows affected [0.00 sec]
mysql> SHOW WARNINGS;
Empty set [0.00 sec]
7 [xem Phần & NBSP; 4.5.1.2, các lệnh của máy khách MySQL]. Ví dụ:mysql client, you can enable and disable automatic warnings display using the mysql> SET sql_notes = 1;
mysql> DROP TABLE IF EXISTS test.no_such_table;
Query OK, 0 rows affected, 1 warning [0.00 sec]
mysql> SHOW WARNINGS;
+-------+------+------------------------------------+
| Level | Code | Message |
+-------+------+------------------------------------+
| Note | 1051 | Unknown table 'test.no_such_table' |
+-------+------+------------------------------------+
1 row in set [0.00 sec]
mysql> SET sql_notes = 0;
mysql> DROP TABLE IF EXISTS test.no_such_table;
Query OK, 0 rows affected [0.00 sec]
mysql> SHOW WARNINGS;
Empty set [0.00 sec]
4 and mysql> SET sql_notes = 1;
mysql> DROP TABLE IF EXISTS test.no_such_table;
Query OK, 0 rows affected, 1 warning [0.00 sec]
mysql> SHOW WARNINGS;
+-------+------+------------------------------------+
| Level | Code | Message |
+-------+------+------------------------------------+
| Note | 1051 | Unknown table 'test.no_such_table' |
+-------+------+------------------------------------+
1 row in set [0.00 sec]
mysql> SET sql_notes = 0;
mysql> DROP TABLE IF EXISTS test.no_such_table;
Query OK, 0 rows affected [0.00 sec]
mysql> SHOW WARNINGS;
Empty set [0.00 sec]
5 commands, respectively, or their shortcuts, mysql> SET sql_notes = 1;
mysql> DROP TABLE IF EXISTS test.no_such_table;
Query OK, 0 rows affected, 1 warning [0.00 sec]
mysql> SHOW WARNINGS;
+-------+------+------------------------------------+
| Level | Code | Message |
+-------+------+------------------------------------+
| Note | 1051 | Unknown table 'test.no_such_table' |
+-------+------+------------------------------------+
1 row in set [0.00 sec]
mysql> SET sql_notes = 0;
mysql> DROP TABLE IF EXISTS test.no_such_table;
Query OK, 0 rows affected [0.00 sec]
mysql> SHOW WARNINGS;
Empty set [0.00 sec]
6 and mysql> SET sql_notes = 1;
mysql> DROP TABLE IF EXISTS test.no_such_table;
Query OK, 0 rows affected, 1 warning [0.00 sec]
mysql> SHOW WARNINGS;
+-------+------+------------------------------------+
| Level | Code | Message |
+-------+------+------------------------------------+
| Note | 1051 | Unknown table 'test.no_such_table' |
+-------+------+------------------------------------+
1 row in set [0.00 sec]
mysql> SET sql_notes = 0;
mysql> DROP TABLE IF EXISTS test.no_such_table;
Query OK, 0 rows affected [0.00 sec]
mysql> SHOW WARNINGS;
Empty set [0.00 sec]
7 [see Section 4.5.1.2, “mysql Client
Commands”]. For example: mysql> \W
Show warnings enabled.
mysql> SELECT 1/0;
+------+
| 1/0 |
+------+
| NULL |
+------+
1 row in set, 1 warning [0.03 sec]
Warning [Code 1365]: Division by 0
mysql> \w
Show warnings disabled.