为什么执行“DROP INDEX IF EXISTS”会生成MySQL的注释?

huangapple go评论50阅读模式
英文:

Why DROP INDEX IF EXISTS generates a MySQL note

问题

I'm using MariaDB and I have a sql file which looks like this:

create table table1(
id int auto_increment primary key,
name varchar(50))
);
drop index if exists my_index on table1;
create fulltext index my_index on table1(name);

When i run this file with source file.sql it generates this warning:

+-------+------+--------------------------------------------------------------------------+
| Level | Code | Message |
+-------+------+--------------------------------------------------------------------------+
| Note | 1091 | Can't DROP 'my_index'; check that column/key exists |
+-------+------+--------------------------------------------------------------------------+

Is there a way to take this warning away?

英文:

I'm using MariaDB and I have a sql file which looks like this:

create table table1(
     id int auto_increment primary key,
     name varchar(50))
);
drop index if exists my_index on table1;
create fulltext index my_index on table1(name);

When i run this file with source file.sql it generates this warning:

+-------+------+--------------------------------------------------------------------------+
| Level | Code | Message                                                                  |
+-------+------+--------------------------------------------------------------------------+
| Note  | 1091 | Can't DROP 'my_index'; check that column/key exists                      |
+-------+------+--------------------------------------------------------------------------+

Is there a way to take this warning away?

答案1

得分: 2

如果使用了IF EXISTS子句,那么如果索引不存在,MariaDB将返回警告而不是错误。希望这有所帮助。

英文:

This is what I have founded here: https://mariadb.com/kb/en/drop-index/

> If the IF EXISTS clause is used, then MariaDB will return a warning
> instead of an error if the index does not exist.

Hope this helps.

huangapple
  • 本文由 发表于 2020年1月3日 21:25:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/59579403.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定