Monday, 19 December 2016

How to DROP INDEX in Cassandra Database

We can drop a secondary index by using the DROP INDEX statement.


DROP INDEX index_name

cqlsh:payroll> CREATE INDEX erank ON exam_year_name (rank);
cqlsh:payroll> select * from exam_year_name where rank=1;
 exam_year | exam_name                 | rank | examlist_name
      2015 | Public Service Commission |    1 |         UPPSC
      2015 |  Teacher Eligibility Test |    1 |          CTET
(2 rows)
cqlsh:payroll> Drop index erank;

Keep in Mind:-
  • The DROP INDEX statement is used to drop an existing secondary index
  • If the index does not exist, the statement will return an error. to avoid this use IF EXISTS

No comments:

Post a Comment

Note: only a member of this blog may post a comment.