How does "DROP TABLE IF EXISTS" work in Kassandra?

I am trying to understand the syntax DROP TABLE IF EXISTSin Cassandra.

DROP TABLE IF EXISTS nonexistanttable;doesn't seem to work:

$ ./cqlsh
Connected to Test Cluster at localhost:9160.
[cqlsh 4.1.1 | Cassandra 2.0.5 | CQL spec 3.1.1 | Thrift protocol 19.39.0]
Use HELP for help.
cqlsh> USE Foo;
cqlsh:foo> DROP TABLE IF EXISTS bar;
Bad Request: unconfigured columnfamily bar

What am I doing wrong?

+4
source share
1 answer

The idea DROP TABLE IF EXISTSis that you avoid getting an InvalidRequestException "Bad Request: unconfigured columnfamily" by discarding the table only if it is actually created, so your request is correct.

You get an exception because it was a bug in version 2.0.5. This has been fixed for C * 2.0.6, but if you want to see it right away DROP TABLE IF EXISTS, try downloading and creating cassandra from the source:

git clone -b cassandra-2.0 git://git.apache.org/cassandra.git cassandra
cd cassandra
ant build
+4
source

All Articles