How do I show a MySQL warning that just happened?

前端 未结 3 1526
执念已碎
执念已碎 2020-12-07 11:10

I just ran a simple MySQL CREATE TABLE statement that produced the line

\"Query OK, 0 rows affected, 1 warning (0.07 sec).\"

I

相关标签:
3条回答
  • 2020-12-07 11:35

    @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.

    0 讨论(0)
  • 2020-12-07 11:36

    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.

    0 讨论(0)
  • 2020-12-07 11:44

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

    You can switch them off again with \w

    0 讨论(0)
提交回复
热议问题