DROP INDEX
DROP INDEX
removes an index from a materialized view. (Non-materialized views do not have any indexes.)
Syntax
Field | Use |
---|---|
IF EXISTS | Do not return an error if the named index doesn’t exist. |
index_name | The name of the index you want to remove. |
CASCADE | Remove the index and its dependent objects. |
RESTRICT | Remove the index. (Default.) |
Note: Since indexes cannot currently have dependent objects, DROP INDEX
, DROP INDEX RESTRICT
, and DROP INDEX CASCADE
all do the same thing.
Examples
Remove an index
SHOW VIEWS;
+-----------------------------------+
| VIEWS |
|-----------------------------------|
| ... |
| q01 |
+-----------------------------------+
SHOW INDEXES ON q01;
+--------------------------------+------------------------+-----
| name | on | ...
|--------------------------------+------------------------+----
| materialize.public.q01_geo_idx | materialize.public.q01 | ...
+--------------------------------+------------------------+-----
You can use the unqualified index name (q01_geo_idx
) rather the fully qualified name (materialize.public.q01_geo_idx
).
You can remove an index with any of the following commands:
-
DROP INDEX q01_geo_idx;
-
DROP INDEX q01_geo_idx RESTRICT;
-
DROP INDEX q01_geo_idx CASCADE;
Do not issue an error if attempting to remove a nonexistent index
DROP INDEX IF EXISTS q01_geo_idx;
Privileges
The privileges required to execute this statement are:
- Ownership of the dropped index.
USAGE
privileges on the containing schema.