Home > Database > Mysql Tutorial > How to suppress warnings in MySQL?

How to suppress warnings in MySQL?

PHPz
Release: 2023-09-16 22:33:04
forward
1058 people have browsed it

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)
Copy after login

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)
Copy after login

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

mysql> show warnings;
Copy after login

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)
Copy after login

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)
Copy after login

Let us abandon the above table again-

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

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)
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template