Question

I am trying to drop a table/column family from my database but I am unable to do it.

I have tried the following commands and their responses are:

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'

and also:

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

does someone know how to drop tables/column families in Cassandra 2.0.5?

I am using:

[cqlsh 4.1.1 | Cassandra 2.0.5 | CQL spec 3.1.1 | Thrift protocol 19.39.0]
Was it helpful?

Solution

I'm going to go through the errors you got so you can get a clear picture of what's going on, but firstly a note that columnfamily == table.

cqlsh:testreducedb> DROP_COLUMNFAMILY largest_time_total; Bad Request: line 1:0 no viable alternative at input 'DROP_COLUMNFAMILY'

DROP_COLUMNFAMILY Isn't a valid command. It should be DROP COLUMNFAMILY or DROP TABLE assuming you're already using the keyspace (database) that stores the aforementioned table (aka columnfamily). If you haven't specified the keyspace to your client then you can specify it in the drop statement:

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> DROP COLUMNFAMILY largest_time_total; Bad Request: unconfigured columnfamily largest_time_total

The column family doesn't actually exist. Based on just seeing cqlsh my bet is that you haven't specified using the keyspace that stores *largest_time_total*. Try using USE <keyspace> in cqlsh, e.g. USE grocerystore;

The rest of the errors are just repetitions of the above.

P.S You were really close with this one, but there's one space too many between COLUMN and FAMILY :)

cqlsh:testreducedb> DROP COLUMN FAMILY largest_time_total; Bad Request: line 1:5 no viable alternative at input 'COLUMN'

Try:

USE testreducedb;
DROP COLUMNFAMILY largest_time_total;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top