CQL for Cassandra 2.x

Removing a keyspace, schema, or data

To remove data, you can set column values for automatic removal using the TTL (time-to-expire) table attribute. You can also drop a table or keyspace, and delete keyspace column metadata.

Dropping a table or keyspace

You drop a table or keyspace using the DROP command.

Procedure

  1. Drop the users table.
    cqlsh:demodb> DROP TABLE users;
  2. Drop the demodb keyspace.
    cqlsh:demodb> DROP KEYSPACE demodb;

Deleting columns and rows

CQL provides the DELETE command to delete a column or row. Deleted values are removed completely by the first compaction following deletion.

Procedure

  1. Deletes user jsmith's session token column.
    cqlsh:demodb> DELETE session_token FROM users where pk = 'jsmith';
  2. Delete jsmith's entire row.
    cqlsh:demodb> DELETE FROM users where pk = 'jsmith';
Show/hide