DROP INDEX removes indexes from tables.
The
DROP INDEX statement performs a schema change. For more information about how online schema changes work in CockroachDB, see .Synopsis
Required privileges
The user must have theCREATE on each specified table.
Parameters
Viewing schema changes
This schema change statement is registered as a job. You can view long-running jobs with .Examples
Setup
The following examples use MovR, a fictional vehicle-sharing application, to demonstrate CockroachDB SQL statements. For more information about the MovR example application and dataset, see . To follow along, run to start a temporary, in-memory cluster with themovr dataset preloaded:
Remove an index with no dependencies
created as part of a statement cannot be removed without using . Unique indexes created with do not have this limitation. Suppose you create an index on thename and city columns of the users table:
DROP INDEX statement:
Remove an index and dependent objects with CASCADE
CASCADE drops all dependent objects without listing them, which can lead to inadvertent and difficult-to-recover losses. To avoid potential harm, we recommend dropping objects individually in most cases.
Suppose you create a constraint on the id and name columns of the users table:
id and name, CockroachDB automatically creates an index:
UNIQUE constraint is dependent on the id_name_unique index, so you cannot drop the index with a simple DROP INDEX statement:
CASCADE:

