Dropping tables and keyspaces
The DROP TABLE
statement removes a table and the table data. The
DROP KEYSPACE
statement removes the keyspace and all of the objects
in the keyspace.
To remove a table and the table data, use the DROP TABLE
statement.
To remove a keyspace and all of the objects in it, use the DROP
KEYSPACE
statement.
To perform the removal only if the object exists, add the IF
EXISTS
clause.
-
This
DROP TABLE
example drops therank_by_year_and_name
table:DROP TABLE IF EXISTS cycling.rank_by_year_and_name;
-
This
DROP KEYSPACE
example drops thecycling
keyspace:DROP KEYSPACE cycling IF EXISTS;