DROP TABLE
Immediately and irreversibly removes a table, including all data contained in the table.
You must drop all materialized views based on the table before dropping the table.
If any materialized views are based on the table, DROP TABLE fails with the following error message:
InvalidRequest: Error from server: code=2200 [Invalid query] message=
"Cannot drop table when materialized views still depend on it"
Synopsis
DROP TABLE [ IF EXISTS ] [<keyspace_name>.]<table_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 table if it exists, or silently do nothing if the named table doesn’t exist in the keyspace. Otherwise, an error is returned if the table doesn’t exist.
- keyspace_name
-
Optional. Name of the keyspace containing the table to drop. If not specified, the current keyspace is used.
- table_name
-
Name of the table to drop.
|
On Linux systems, object names, such as keyspace and table names, are case-sensitive. CQL converts object names to lowercase unless enclosed in double quotation marks. |
Example
Drop the cyclist_name table in the cycling keyspace:
DROP TABLE IF EXISTS cycling.cyclist_name;