How to CREATE INDEX
Using the CREATE INDEX statement we can create a secondary index on a table.
Syntax: - CREATE INDEX [ index_name ] ON table_name (column_name)
Remark Point: -
- An index name is optional and must be unique within a keyspace.
- If you do not provide a name, Cassandra will assign a name like column_name_idx.
Example:-
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> CREATE INDEX userIndex ON NerdMovies (user); cqlsh:payroll> CREATE INDEX ON Mutants (abilityId); cqlsh:payroll> CREATE INDEX ON users (keys(favs));
No comments:
Post a comment