Cassandra DROP Index
To drop a specified index in Cassandra, the DROP INDEX command is used. The index name is TableName_ColumnName_idx, in case if the index name was not specified during index creation.
Syntax 1:
DROP INDEX |
Syntax 2:
Drop index IF EXISTS Keyspace_Name.Index_Name |
Important Points:
- An error will be displayed by default if the index does not exist.
- The keyspace name needs to be specified with the index name during the index creation or else the index will be dropped from the current keyspace.
Example:
Drop index IF EXISTS example.name |
Explanation:
Here, the ‘example’ is the keyspace that contains the table ’employees’. The ‘name’ is a column in the ’employees’ table. We are dropping the index from the ‘name’ column.