Rechercher dans le manuel MySQL
13.7.6.40 SHOW WARNINGS Syntax
SHOW WARNINGS
is a diagnostic
statement that displays information about the conditions
(errors, warnings, and notes) resulting from executing a
statement in the current session. Warnings are generated for DML
statements such as INSERT
,
UPDATE
, and
LOAD DATA
as well as DDL
statements such as CREATE TABLE
and ALTER TABLE
.
The LIMIT
clause has the same syntax as for
the SELECT
statement. See
Section 13.2.10, “SELECT Syntax”.
SHOW WARNINGS
is also used
following EXPLAIN
, to display the
extended information generated by
EXPLAIN
. See
Section 8.8.3, “Extended EXPLAIN Output Format”.
SHOW WARNINGS
displays
information about the conditions resulting from execution of the
most recent nondiagnostic statement in the current session. If
the most recent statement resulted in an error during parsing,
SHOW WARNINGS
shows the resulting
conditions, regardless of statement type (diagnostic or
nondiagnostic).
The SHOW COUNT(*)
WARNINGS
diagnostic statement displays the total
number of errors, warnings, and notes. You can also retrieve
this number from the
warning_count
system variable:
A difference in these statements is that the first is a
diagnostic statement that does not clear the message list. The
second, because it is a SELECT
statement is considered nondiagnostic and does clear the message
list.
A related diagnostic statement, SHOW
ERRORS
, shows only error conditions (it excludes
warnings and notes), and
SHOW COUNT(*)
ERRORS
statement displays the total number of errors.
See Section 13.7.6.17, “SHOW ERRORS Syntax”. GET
DIAGNOSTICS
can be used to examine information for
individual conditions. See Section 13.6.7.3, “GET DIAGNOSTICS Syntax”.
Here is a simple example that shows data-conversion warnings for
INSERT
. The example assumes that
strict SQL mode is disabled. With strict mode enabled, the
warnings would become errors and terminate the
INSERT
.
- Query OK, 0 rows affected (0.05 sec)
- *************************** 1. row ***************************
- Level: Warning
- Code: 1265
- *************************** 2. row ***************************
- Level: Warning
- Code: 1048
- *************************** 3. row ***************************
- Level: Warning
- Code: 1264
The max_error_count
system
variable controls the maximum number of error, warning, and note
messages for which the server stores information, and thus the
number of messages that SHOW
WARNINGS
displays. To change the number of messages
the server can store, change the value of
max_error_count
.
max_error_count
controls only
how many messages are stored, not how many are counted. The
value of warning_count
is not
limited by max_error_count
,
even if the number of messages generated exceeds
max_error_count
. The following
example demonstrates this. The ALTER
TABLE
statement produces three warning messages
(strict SQL mode is disabled for the example to prevent an error
from occuring after a single conversion issue). Only one message
is stored and displayed because
max_error_count
has been set to
1, but all three are counted (as shown by the value of
warning_count
):
- +-----------------+-------+
- +-----------------+-------+
- | max_error_count | 1024 |
- +-----------------+-------+
- Query OK, 0 rows affected (0.00 sec)
- +---------+------+----------------------------------------+
- | Level | Code | Message |
- +---------+------+----------------------------------------+
- +---------+------+----------------------------------------+
- +-----------------+
- | @@warning_count |
- +-----------------+
- | 3 |
- +-----------------+
To disable message storage, set
max_error_count
to 0. In this
case, warning_count
still
indicates how many warnings occurred, but messages are not
stored and cannot be displayed.
The sql_notes
system variable
controls whether note messages increment
warning_count
and whether the
server stores them. By default,
sql_notes
is 1, but if set to
0, notes do not increment
warning_count
and the server
does not store them:
- Query OK, 0 rows affected, 1 warning (0.00 sec)
- +-------+------+------------------------------------+
- | Level | Code | Message |
- +-------+------+------------------------------------+
- +-------+------+------------------------------------+
- Query OK, 0 rows affected (0.00 sec)
The MySQL server sends to each client a count indicating the
total number of errors, warnings, and notes resulting from the
most recent statement executed by that client. From the C API,
this value can be obtained by calling
mysql_warning_count()
. See
Section 28.7.7.82, “mysql_warning_count()”.
In the mysql client, you can enable and
disable automatic warnings display using the
warnings
and nowarning
commands, respectively, or their shortcuts,
\W
and \w
(see
Section 4.5.1.2, “mysql Client Commands”). For example:
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 26/06/2006 gemaakt, de laatste keer de 26/10/2018 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/mysql-rf-show-warnings.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.
Referenties
Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.