doc/user/content/sql/drop-index.md
DROP INDEX removes an index from Materialize.
DROP INDEX [IF EXISTS] <index_name> [CASCADE|RESTRICT];
| Syntax element | Description |
|---|---|
| IF EXISTS | Optional. If specified, do not return an error if the specified index does not exist. |
<index_name> | Index to drop. |
| CASCADE | Optional. If specified, remove the index and its dependent objects. |
| RESTRICT | Optional. Remove the index. (Default.) |
{{< note >}}
Since indexes do not have dependent objects, DROP INDEX, DROP INDEX RESTRICT, and DROP INDEX CASCADE are equivalent.
{{< /note >}}
To execute the DROP INDEX statement, you need:
{{% include-headless "/headless/sql-command-privileges/drop-index" %}}
{{< tip >}}
In the Materialize Console, you can view existing indexes in the Database
object explorer. Alternatively, you can use the
SHOW INDEXES command.
{{< /tip >}}
Using the DROP INDEX commands, the following example drops an index named q01_geo_idx.
DROP INDEX q01_geo_idx;
If the index q01_geo_idx does not exist, the above operation returns an error.
You can specify the IF EXISTS option so that the DROP INDEX command does
not return an error if the index to drop does not exist.
DROP INDEX IF EXISTS q01_geo_idx;