...

/

CQL DDL: USE, DESCRIBE, ALTER, DROP KEYSPACE statements

CQL DDL: USE, DESCRIBE, ALTER, DROP KEYSPACE statements

Master CQL DDL operations to USE, DESCRIBE, DROP, and ALTER keyspaces, with syntax and examples.

Keyspace related CQL DDL

CQL offers the following keyspace related commands. We will use the CQL shell to execute these commands. 

Important: Please note that the Terminal widget is NOT persistent. Keyspaces created in a terminal session are not saved and will not be accessible after the session expires. 

The USE command

The USE command selects a keyspace for subsequent commands. If the USE command is not issued, the keyspace name must always be included with the table name in queries for Cassandra to understand the context of the table being referenced.  

USE <keyspaceName>;

Note: Please refer to syntax conventions for CQL syntax notation details.

Please consider the following query:

SELECT * FROM system.local;

This query uses a fully-qualified table name (prefixed keyspace name system followed by . followed by table name local). The same query may be executed by changing the current keyspace to system with the USE command, and then issuing the query with the table name only.

USE system;
SELECT * FROM local;
...