SHOW WARNINGS [LIMIT [offset,]row_count] SHOW COUNT(*) WARNINGS
SHOW WARNINGS shows the error, warning, and
note messages that resulted from the last statement that
generated messages. It shows nothing if the last statement used
a table and generated no messages. (That is, a statement that
uses a table but generates no messages clears the message list.)
Statements that do not use tables and do not generate messages
have no effect on the message list.
SHOW WARNINGS is implemented as of MySQL
4.1.0. A related statement, SHOW ERRORS,
shows only the errors. See Section 12.5.4.9, “SHOW ERRORS Syntax”.
The SHOW COUNT(*) WARNINGS statement displays
the total number of errors, warnings, and notes. You can also
retrieve this number from the warning_count
variable:
SHOW COUNT(*) WARNINGS; SELECT @@warning_count;
The value of warning_count might be greater
than the number of messages displayed by SHOW
WARNINGS if the max_error_count
system variable is set so low that not all messages are stored.
An example shown later in this section demonstrates how this can
happen.
The LIMIT clause has the same syntax as for
the SELECT statement. See
Section 12.2.7, “SELECT Syntax”.
The MySQL server sends back the total number of errors,
warnings, and notes resulting from the last statement. If you
are using the C API, this value can be obtained by calling
mysql_warning_count(). See
Section 17.2.3.70, “mysql_warning_count()”.
Note that the framework for warnings was added in MySQL 4.1.0,
at which point many statements did not generate warnings. In
4.1.1, the situation is much improved, with warnings generated
for statements such as LOAD DATA INFILE and
DML statements such as INSERT,
UPDATE, CREATE TABLE, and
ALTER TABLE.
The following DROP TABLE statement results in
a note:
mysql>DROP TABLE IF EXISTS no_such_table;mysql>SHOW WARNINGS;+-------+------+-------------------------------+ | Level | Code | Message | +-------+------+-------------------------------+ | Note | 1051 | Unknown table 'no_such_table' | +-------+------+-------------------------------+
Here is a simple example that shows a syntax warning for
CREATE TABLE and conversion warnings for
INSERT:
mysql>CREATE TABLE t1 (a TINYINT NOT NULL, b CHAR(4)) TYPE=MyISAM;Query OK, 0 rows affected, 1 warning (0.00 sec) mysql>SHOW WARNINGS\G*************************** 1. row *************************** Level: Warning Code: 1287 Message: 'TYPE=storage_engine' is deprecated, use 'ENGINE=storage_engine' instead 1 row in set (0.00 sec) mysql>INSERT INTO t1 VALUES(10,'mysql'),(NULL,'test'),->(300,'Open Source');Query OK, 3 rows affected, 4 warnings (0.01 sec) Records: 3 Duplicates: 0 Warnings: 4 mysql>SHOW WARNINGS\G*************************** 1. row *************************** Level: Warning Code: 1265 Message: Data truncated for column 'b' at row 1 *************************** 2. row *************************** Level: Warning Code: 1263 Message: Data truncated, NULL supplied to NOT NULL column 'a' at row 2 *************************** 3. row *************************** Level: Warning Code: 1264 Message: Data truncated, out of range for column 'a' at row 3 *************************** 4. row *************************** Level: Warning Code: 1265 Message: Data truncated for column 'b' at row 3 4 rows in set (0.00 sec)
The maximum number of error, warning, and note messages to store
is controlled by the max_error_count system
variable. By default, its value is 64. To change the number of
messages you want stored, change the value of
max_error_count. In the following example,
the ALTER TABLE statement produces three
warning messages, but only one is stored because
max_error_count has been set to 1:
mysql>SHOW VARIABLES LIKE 'max_error_count';+-----------------+-------+ | Variable_name | Value | +-----------------+-------+ | max_error_count | 64 | +-----------------+-------+ 1 row in set (0.00 sec) mysql>SET max_error_count=1;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>SELECT @@warning_count;+-----------------+ | @@warning_count | +-----------------+ | 3 | +-----------------+ 1 row in set (0.01 sec) mysql>SHOW WARNINGS;+---------+------+----------------------------------------+ | Level | Code | Message | +---------+------+----------------------------------------+ | Warning | 1263 | Data truncated for column 'b' at row 1 | +---------+------+----------------------------------------+ 1 row in set (0.00 sec)
To disable warnings, set max_error_count to
0. In this case, warning_count still
indicates how many warnings have occurred, but none of the
messages are stored.
As of MySQL 4.1.11, you can set the SQL_NOTES
session variable to 0 to cause Note-level
warnings not to be recorded.

User Comments
I didn't see this mentioned in the docs explicitly, but the warnings insofar as I can tell are per connection. That is to say, you won't be able to see warnings from other people, even if you do have rights over all tables.
In the unix framework, it becomes commonplace to believe that the "root" account can (or should) be able to see this information. This does not seem to be the case, at least for some configurations (unless it is logged to a file).
I mention this because of my initial expectations of "mysqlimport" command warnings to be browsable through a new (or existing) "root" connection to the database.
Add your own comment.