如何在cassandra 2.0.5中DROP表或列系列?

时间:2014-04-05 20:17:32

标签: cassandra cql cassandra-2.0

我正在尝试从我的数据库中删除一个表/列系列,但我无法执行此操作。

我尝试了以下命令,其响应是:

cqlsh:testreducedb> DROP_COLUMNFAMILY largest_time_total;
Bad Request: line 1:0 no viable alternative at input 'DROP_COLUMNFAMILY'
cqlsh:testreducedb> DROP COLUMNFAMILY largest_time_total;
Bad Request: unconfigured columnfamily largest_time_total
cqlsh:testreducedb> DROP COLUMN FAMILY largest_time_total;
Bad Request: line 1:5 no viable alternative at input 'COLUMN'
cqlsh:testreducedb> DROP COLUMN FAMILY 'largest_time_total';
Bad Request: line 1:5 no viable alternative at input 'COLUMN'
cqlsh:testreducedb> DROP COLUMN FAMILY "largest_time_total";
Bad Request: line 1:5 no viable alternative at input 'COLUMN'

还有:

cqlsh:testreducedb> DROP_TABLE largest_time_total;
Bad Request: line 1:0 no viable alternative at input 'DROP_TABLE'
cqlsh:testreducedb> DROP TABLE largest_time_total;
Bad Request: unconfigured columnfamily largest_time_total
cqlsh:testreducedb> DROP TABLE 'largest_time_total';
Bad Request: line 1:11 no viable alternative at input 'largest_time_total'
cqlsh:testreducedb> DROP TABLE "largest_time_total";
Bad Request: unconfigured columnfamily largest_time_total

有人知道如何在Cassandra 2.0.5中删除表/列系列吗?

我正在使用:

[cqlsh 4.1.1 | Cassandra 2.0.5 | CQL spec 3.1.1 | Thrift protocol 19.39.0]

1 个答案:

答案 0 :(得分:5)

我将经历你所得到的错误,这样你就可以清楚地了解正在发生的事情,但首先要注意的是listfamily == table。

  

cqlsh:testreducedb> DROP_COLUMNFAMILY largest_time_total;   错误请求:第1行:0在输入处没有可行的选择' DROP_COLUMNFAMILY'

DROP_COLUMNFAMILY不是有效的命令。它应该是 DROP COLUMNFAMILY DROP TABLE ,假设您已经在使用存储上述表(也就是columnfamily)的键空间(数据库)。如果您还没有为客户端指定密钥空间,则可以在drop语句中指定它:

DROP TABLE <keyspace>.<columnfamily>;
DROP TABLE <keyspace>.<table>;
# the below is an actual statement assuming grocerystore is the keyspace and
# shoppers is the columnfamily 
DROP TABLE "grocerystore"."shoppers";
  

cqlsh:testreducedb&GT; DROP COLUMNFAMILY largest_time_total;   错误请求:未配置的columnfamily largest_time_total

列系列实际上并不存在。基于看到 cqlsh ,我的赌注是你没有使用存储* largest_time_total *的键空间指定。尝试在cqlsh中使用USE <keyspace>,例如USE grocerystore;

其余的错误只是上述重复。

P.S 你真的很接近这个,但在COLUMNFAMILY之间有一个太多的空间:)

  

cqlsh:testreducedb&GT; DROP COLUMN FAMILY largest_time_total;   错误请求:第1:5行在输入&#39; COLUMN&#39;

中没有可行的选择

尝试:

USE testreducedb;
DROP COLUMNFAMILY largest_time_total;