Skip to content
Developer Edition runs on one host and does not require a product license file. Need multi-host deployment or performance testing at scale? Explore Enterprise Edition

DROP INDEX statement

The DROP INDEX statement deletes an index from a specific graph or temporary graph.

To specify the graph or temporary graph, use either of the following methods:

  • Add a USE clause before this statement to set the working graph.
  • Use SESSION SET to set the graph or temporary graph for the current session in advance.

If both methods are used, the one specified in the USE clause takes precedence. If neither is used, an error occurs.

Notes

When a DROP INDEX statement is executed to destroy an index, the index data is not immediately physically deleted from the Storage service (disk space remains occupied). Instead, the data is permanently deleted during subsequent RocksDB Compaction operations.

You can manually submit a COMPACT job to force the physical deletion of the data. The actual immediate deletion depends on the current level of the data in RocksDB's LSM-tree hierarchy.

Note

An operation involving a non-default schema or an object in it requires access to the schema, either implicitly or through an explicit USAGE grant, as well as the privilege required for the operation. The schema access check and the privilege check for the requested operation are independent; satisfying one does not satisfy the other. Schema access control does not apply to temporary graphs or built-in procedures and functions. For more information, see Schema access control.

Prerequisites

  • To drop an index from a graph, you must either be the owner of the graph, be granted to perform the action INDEX on the graph, or be granted to perform the action DROP ANY INDEX on the used schema. For more information, see Roles and privileges.
  • To drop an index from a temporary graph, you must be the user with the role ADMIN or the owner of the temporary graph.

Syntax

drop_index_statement
DROP INDEX IF EXISTS index_name

drop_index_statement ::=
    'DROP' 'INDEX' ('IF EXISTS')? index_name 

Parameters

IF EXISTS

This clause checks if the index to be deleted exists. If it does not exist, the index is not deleted and no exception is thrown.

If you do not specify this clause, an exception is thrown if the index to be deleted does not exist.

index_name

The name of the index to be dropped.

Examples

Drop a normal index on a node type of a graph

USE movie DROP INDEX IF EXISTS idx_actor_age

The preceding example drops the index idx_actor_age that was created in CREATE NORMAL INDEX.

Drop a normal index on an edge type of a graph

USE movie DROP INDEX IF EXISTS idx_watch_rating

The preceding example drops the index idx_watch_rating that was created in CREATE NORMAL INDEX.

Drop a normal index on a node type of a temporary graph

USE #movie_temporary_graph DROP INDEX IF EXISTS idx_actor_age_temp

The preceding example drops the index idx_actor_age_temp that was created in CREATE NORMAL INDEX.

Drop a normal index on an edge type of a temporary graph

USE #movie_temporary_graph DROP INDEX IF EXISTS idx_watch_rating_temp

The preceding example drops the index idx_watch_rating_temp that was created in CREATE NORMAL INDEX.

Drop a vector index on a node type of a graph

USE ann_test_graph DROP INDEX IF EXISTS idx_node_vec1

The preceding example drops the vector index idx_node_vec1 that was created in CREATE VECTOR INDEX.

Drop a vector index on an edge type of a graph

USE ann_test_graph DROP INDEX IF EXISTS idx_edge_vec2

The preceding example drops the vector index idx_edge_vec2 that was created in CREATE VECTOR INDEX.

Drop a spatial index on a node type of a graph

USE my_graph DROP INDEX IF EXISTS idx_gnode_g

The preceding example drops the spatial index idx_gnode_g that was created in CREATE SPATIAL INDEX.

Drop a spatial index on an edge type of a graph

USE my_graph DROP INDEX IF EXISTS idx_gedge_g

The preceding example drops the spatial index idx_gedge_g that was created in CREATE SPATIAL INDEX.

Drop a full-text index on a node type of a graph

USE movie DROP INDEX IF EXISTS ft_movie

The preceding example drops the full-text index ft_movie that was created in CREATE FULLTEXT INDEX.