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.

  1. This DROP TABLE example drops the rank_by_year_and_name table:
    DROP TABLE IF EXISTS cycling.rank_by_year_and_name;
  2. This DROP KEYSPACE example drops the cycling keyspace:
    DROP KEYSPACE cycling IF EXISTS;