Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I show a MySQL warning that just happened?

Tags:

mysql

People also ask

How do I enable show warnings in MySQL?

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.

How do I view SQL warnings?

The mysql client also has a number of options related to warnings. The \W command will show warnings after every statement, while \w will disable this.

What is the command to see the warning messages?

Correct Option: B The SHOW WARNINGS command is used after executing one of those statements to see the warning messages.


SHOW WARNINGS is the only method I'm aware of, but you have to run it immediately after a query that had warnings attached to it. If you ran any other queries in between, or dropped the connection, then SHOW WARNINGS won't work.

The MySQL manual page for SHOW WARNINGS doesn't indicate any other methods, so I'm fairly certain that you're stuck with it.


You can also set the command line to always display warnings after a query using \W

You can switch them off again with \w


@HorusKol, do you have documentation for that? I couldn't find any. But I did find out that the command line option --show-warnings will do the job, according to the MySQL manual.