英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论