# DROP INDEX

## Syntax

```sql
DROP INDEX [IF EXISTS] index_name ON tbl_name 
    [WAIT n |NOWAIT]
```

## Description

`DROP INDEX` drops the [index](https://mariadb.com/docs/server/ha-and-performance/optimization-and-tuning/optimization-and-indexes) 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](https://mariadb.com/docs/server/reference/sql-statements/transactions/metadata-locking) is active, and this statement will wait until the lock is released. This is also true for non-transactional tables.

See [ALTER TABLE](https://mariadb.com/docs/server/reference/sql-statements/data-definition/alter/alter-table).

Another shortcut, [CREATE INDEX](https://mariadb.com/docs/server/reference/sql-statements/data-definition/create/create-index), allows the creation of an index.

To remove the primary key, `PRIMARY` must be specified as index\_name. Note that [the quotes](https://mariadb.com/docs/server/reference/sql-structure/sql-language-structure/identifier-qualifiers) are necessary, because `PRIMARY` is a keyword.

## Privileges

Executing the `DROP INDEX` statement requires the [INDEX](https://github.com/mariadb-corporation/mariadb-docs/blob/main/server/reference/sql-statements/account-management-sql-commands/grant.md#table-privileges) privilege for the table or the database.

## Online DDL

Online DDL is used by default with InnoDB, when the drop index operation supports it.

See [InnoDB Online DDL Overview](https://mariadb.com/docs/server/server-usage/storage-engines/innodb/innodb-online-ddl/innodb-online-ddl-overview) for more information on online DDL with [InnoDB](https://mariadb.com/docs/server/server-usage/storage-engines/innodb).

## DROP INDEX IF EXISTS ...

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

Sets the lock wait timeout. See [WAIT and NOWAIT](https://mariadb.com/docs/server/reference/sql-statements/transactions/wait-and-nowait).

## Progress Reporting

MariaDB provides progress reporting for `DROP INDEX` statement for clients\
that support the new progress reporting protocol. For example, if you were using the [mariadb](https://mariadb.com/docs/server/clients-and-utilities/mariadb-client/mariadb-command-line-client) client, then the progress report might look like this::

## See Also

* [Getting Started with Indexes](https://mariadb.com/docs/server/mariadb-quickstart-guides/mariadb-indexes-guide)
* [CREATE INDEX](https://mariadb.com/docs/server/reference/sql-statements/data-definition/create/create-index)
* [ALTER TABLE](https://mariadb.com/docs/server/reference/sql-statements/data-definition/alter/alter-table)

<sub>*This page is licensed: GPLv2, originally from*</sub> [<sub>*fill\_help\_tables.sql*</sub>](https://github.com/MariaDB/server/blob/main/scripts/fill_help_tables.sql)

{% @marketo/form formId="4316" %}
