DROP TABLE

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 TABLE statement to remove a table and all of its data from the database.

Syntax

Diagram

DROPTABLEIFEXISTStable_name

Grammar

drop_table ::= DROP TABLE [ IF EXISTS ] table_name;

Where

  • table_name is an identifier (possibly qualified with a keyspace name).

Semantics

  • An error is raised if the specified table_name does not exist unless IF EXISTS option is present.
  • Associated objects to table_name such as prepared statements will be eventually invalidated after the drop statement is completed.

Examples

ycqlsh:example> CREATE TABLE users(id INT PRIMARY KEY, name TEXT);
ycqlsh:example> DROP TABLE users;

See also