DROP KEYSPACE

This page documents a preview version. v2.23 Preview
Preview includes features under active development and is for development and testing only.
For production, use the latest stable version (v2024.1).

Synopsis

Use the DROP KEYSPACE statement to remove a keyspace from the system.

Syntax

Diagram

DROPKEYSPACESCHEMAIFEXISTSkeyspace_name

Grammar

drop_keyspace ::= DROP { KEYSPACE | SCHEMA } [ IF EXISTS ] keyspace_name;

Where

  • keyspace_name is an identifier.

Semantics

  • An error is raised if the specified keyspace_name does not exist unless IF EXISTS option is present.
  • An error is raised if the specified keyspace is non-empty (contains tables or types).

Examples

ycqlsh> CREATE KEYSPACE example;
ycqlsh> DROP KEYSPACE example;
ycqlsh> DROP KEYSPACE IF EXISTS example;

See also