Home  >  Article  >  Database  >  How to suppress warnings in MySQL?

How to suppress warnings in MySQL?

PHPz
PHPzforward
2023-09-16 22:33:04993browse

How to suppress warnings in MySQL?

To suppress warnings, set SQL_NOTES to 0. Let's look at an example.

First, we will set SQL_NOTES to 1 −

mysql> SET sql_notes = 1;
Query OK, 0 rows affected (0.00 sec)

Now, let us delete a table that does not exist. As you can see, a warning message is now visible -

mysql> drop table if exists web.DemoTable;
Query OK, 0 rows affected, 1 warning (0.07 sec)

To view the above warning message, you can simply use the SHOW WARNINGS command -

mysql> show warnings;

This will produce the following output, Show warning message −

+-------+------+-----------------------------------+
| Level | Code | Message                           |
+-------+------+-----------------------------------+
| Note  | 1051 | Unknown table 'web.DemoTable'     |
+-------+------+-----------------------------------+
1 row in set (0.00 sec)

Now, since we need to suppress warnings, use SQL_NOTES and set it to OFF −

mysql> SET sql_notes = 0;
Query OK, 0 rows affected (0.00 sec)

Let us abandon the above table again-

mysql> drop table if exists web.DemoTable;
Query OK, 0 rows affected (0.07 sec)

The above process is called suppressing warnings in MySQL. Now when you try again to get the warning it will show "empty set" like below -

mysql> show warnings;
Empty set (0.00 sec)

The above is the detailed content of How to suppress warnings in MySQL?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete