DROP KEYSPACE
Immediately and permanently removes a keyspace and all objects within the keyspace, including tables, indexes, functions, and data.
|
DataStax recommends that you don’t manually delete system keyspaces, which are critical for cluster operations. This includes the DSEFS keyspace. |
Backup before dropping a keyspace
When auto_snapshot is enabled in cassandra.yaml, the keyspace is automatically backed up on the node where the command is executed.
This feature serves as a lightweight guardrail for unintentional deletions, but it isn’t a replacement for robust backup and recovery processes.
To manually backup the keyspace, see Taking a snapshot.
As long as a valid snapshot exists, you can use it to restore a dropped keyspace.
Synopsis
DROP KEYSPACE [ IF EXISTS ] <keyspace_name>;
| Syntax conventions | Description |
|---|---|
UPPERCASE |
Literal keyword. |
Lowercase |
Not literal. |
|
Variable value. Replace with a user-defined value. |
|
Optional.
Square brackets ( |
|
Group.
Parentheses ( |
|
Or.
A vertical bar ( |
|
Repeatable.
An ellipsis ( |
|
Single quotation ( |
|
Map collection.
Braces ( |
|
Set, list, map, or tuple.
Angle brackets ( |
|
End CQL statement.
A semicolon ( |
|
Separate the command line options from the command arguments with two hyphens ( |
|
Search CQL only: Single quotation marks ( |
|
Search CQL only: Identify the entity and literal value to overwrite the XML element in the schema and solrConfig files. |
Options
- IF EXISTS
-
Optional. Drop the keyspace if it exists, or silently do nothing if the named keyspace doesn’t exist. Otherwise, an error is returned if the keyspace doesn’t exist.
- keyspace_name
-
The name of the keyspace to drop.
Examples
|
To get keyspace names or verify that a keyspace was dropped, use |
- Drop a keyspace
-
DROP KEYSPACE cycling; - Drop a keyspace if it exists
-
DROP KEYSPACE IF EXISTS cycling;