Heim  >  Artikel  >  Datenbank  >  Wie unterdrücke ich Warnungen in MySQL?

Wie unterdrücke ich Warnungen in MySQL?

PHPz
PHPznach vorne
2023-09-16 22:33:04993Durchsuche

Wie unterdrücke ich Warnungen in MySQL?

为了抑制警告,请将 SQL_NOTES 设置为 0。让我们看一个例子。

首先,我们将把 SQL_NOTES 设置为 1 −

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

现在,让我们删除一个不存在的表。正如您所看到的,现在可以看到一条警告消息 -

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

要查看上面的警告消息,您只需使用 SHOW WARNINGS 命令 -

mysql> show warnings;

这将产生以下输出,显示警告消息 −

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

现在,由于我们需要抑制警告,使用 SQL_NOTES 并将其设置为 OFF −

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

让我们再次放弃上面的表格 -

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

上述过程称为MySQL中的抑制警告。现在,当您再次尝试获取警告时,它将显示如下所示的“空集”-

mysql> show warnings;
Empty set (0.00 sec)

Das obige ist der detaillierte Inhalt vonWie unterdrücke ich Warnungen in MySQL?. Für weitere Informationen folgen Sie bitte anderen verwandten Artikeln auf der PHP chinesischen Website!

Stellungnahme:
Dieser Artikel ist reproduziert unter:tutorialspoint.com. Bei Verstößen wenden Sie sich bitte an admin@php.cn löschen