DROP INDEX [IF EXISTS] index_name ON tbl_name [WAIT n |NOWAIT] [algorithm_option | lock_option] ... algorithm_option: ALGORITHM [=] {DEFAULT|INPLACE|COPY|NOCOPY|INSTANT} lock_option: LOCK [=] {DEFAULT|NONE|SHARED|EXCLUSIVE}
DROP INDEX
drops the index named index_name
from the table tbl_name
. This statement is mapped to an ALTER TABLE
statement to drop the index.
If another connection is using the table, a metadata lock is active, and this statement will wait until the lock is released. This is also true for non-transactional tables.
See ALTER TABLE
.
Another shortcut, CREATE INDEX
, allows the creation of an index.
To remove the primary key, `PRIMARY`
must be specified as index_name. Note that the quotes are necessary, because PRIMARY
is a keyword.
Executing the DROP INDEX
statement requires the INDEX
privilege for the table or the database.
In MariaDB 10.0 and later, online DDL is supported with the ALGORITHM
and LOCK
clauses.
See InnoDB Online DDL Overview for more information on online DDL with InnoDB.
DROP INDEX IF EXISTS ...
The IF EXISTS
clause was added in MariaDB 10.1.4.
If the IF EXISTS
clause is used, then MariaDB will return a warning instead of an error if the index does not exist.
WAIT/NOWAIT
Set the lock wait timeout. See WAIT and NOWAIT.
ALGORITHM
See ALTER TABLE: ALGORITHM for more information.
LOCK
See ALTER TABLE: LOCK for more information.
MariaDB provides progress reporting for DROP INDEX
statement for clients that support the new progress reporting protocol. For example, if you were using the mysql
client, then the progress report might look like this::
© 2019 MariaDB
Licensed under the Creative Commons Attribution 3.0 Unported License and the GNU Free Documentation License.
https://mariadb.com/kb/en/drop-index/