数据库教程-Cassandra删除索引

跨零代码为大家提供高品质的解决方案,请大家多多来访,跨零不胜感激,在此谢过。

DROP INDEX命令用于删除指定的索引。 如果索引创建时未指定索引名称,则索引名称为TableName_ColumnName_idx

语法

DROP INDEX <identifier> 

或者 –

Drop index IF EXISTS KeyspaceName.IndexName 

删除索引的规则

  • 如果索引不存在,它将返回错误,除非您使用IF EXISTS,否则不返回任何操作。
  • 在创建索引期间,您必须使用索引名称指定keyspace名称,否则将当前键空间中的索引删除。

示例:

下面举个例子来演示如何删除某列上的索引。 在这里,我们将创建的索引放在表“student”中的“student_name”列中。键空间的名称是“yiibai_ks”。

Drop index IF EXISTS yiibai_ks.student_name_index; 

如下语句 –

## 首先创建一个索引: student_name_index cqlsh:yiibai_ks> CREATE INDEX student_name_index ON student (student_name); cqlsh:yiibai_ks> describe student;  CREATE TABLE yiibai_ks.student (     student_id int PRIMARY KEY,     student_fees varint,     student_name text ) WITH bloom_filter_fp_chance = 0.01     AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}     AND comment = ''     AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}     AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}     AND crc_check_chance = 1.0     AND dclocal_read_repair_chance = 0.1     AND default_time_to_live = 0     AND gc_grace_seconds = 864000     AND max_index_interval = 2048     AND memtable_flush_period_in_ms = 0     AND min_index_interval = 128     AND read_repair_chance = 0.0     AND speculative_retry = '99PERCENTILE'; CREATE INDEX student_name_index ON yiibai_ks.student (student_name);  ## 删除索引 = student_name_index cqlsh:yiibai_ks> Drop index IF EXISTS student_name_index; cqlsh:yiibai_ks> describe student;  CREATE TABLE yiibai_ks.student (     student_id int PRIMARY KEY,     student_fees varint,     student_name text ) WITH bloom_filter_fp_chance = 0.01     AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}     AND comment = ''     AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}     AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}     AND crc_check_chance = 1.0     AND dclocal_read_repair_chance = 0.1     AND default_time_to_live = 0     AND gc_grace_seconds = 864000     AND max_index_interval = 2048     AND memtable_flush_period_in_ms = 0     AND min_index_interval = 128     AND read_repair_chance = 0.0     AND speculative_retry = '99PERCENTILE';  cqlsh:yiibai_ks> 

从“student_name”列中删除索引。

cqlsh:yiibai_ks> Drop index student_name_index; InvalidRequest: Error from server: code=2200 [Invalid query] message="Index 'student_name_index' could not be found in any of the tables of keyspace 'yiibai_ks'" cqlsh:yiibai_ks> 

  

从零到一,创造未来!跨零综合IT问题解决服务站,欢迎你的到来。Oracle数据库教程 cassandra教程 只为你绽放。

本文固定链接: http://kua0.com/2019/01/23/数据库教程-cassandra删除索引/

为您推荐

发表评论

电子邮件地址不会被公开。 必填项已用*标注