Name
SHOW WARNINGS
Synopsis
SHOW WARNINGS [LIMIT [offset
,]count
] SHOW COUNT(*) WARNINGS
Use this statement to display warning messages, error
messages, and notes for previous SQL statements for the current
session. This statement is available as of version 4.1 of MySQL. To
find out the number of such messages generated by the previous
statement in the session, use COUNT(*)
. Use the
LIMIT
clause to limit the number of messages
displayed. An offset can be given along with the limit to specify a
starting point for displaying messages. Here are a couple of examples
of how you can use this statement:
INSERT INTO clients (client_name, telephone) VALUES('Marie & Associates', '504-486-1234'); Query OK, 1 row affected, 1 warning (0.00 sec) SHOW COUNT(*) WARNINGS; +-------------------------+ | @@session.warning_count | +-------------------------+ | 1 | +-------------------------+ SHOW WARNINGS; +---------+------+--------------------------------------------------+ | Level | Code | Message | +---------+------+--------------------------------------------------+ | Warning | 1265 | Data truncated for column 'client_name' at row 1 | +---------+------+--------------------------------------------------+
In this example, we enter the name of a client and her telephone
number in the table clients
, but in the results we
see that one warning is issued. The second statement returns the
number of messages; of course, the last line of the results from the
INSERT
already told us this. Notice that the results ...
Get MySQL in a Nutshell, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.