DROP TYPE
Immediately and irreversibly removes a UDT (user-defined type). The ability to drop a UDT that is defined in a table depends on whether the type is frozen or non-frozen.
Dropping a user-defined type that is in use by a table, an index, or another type is not supported. In this case, you must first drop the dependent objects before dropping the type. |
See also: CREATE TYPE
Syntax
DROP TYPE [ IF EXISTS ] [<keyspace_name>.]<type_name> ;
Syntax legend
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. |
Parameters
Parameter | Description | Default |
---|---|---|
|
Optional. Name of the keyspace that contains the table to index. |
If no name is specified, the current keyspace is used. |
|
Name of the type to drop. |
Usage notes
There are several issues that may cause an error when attempting to drop a UDT:
-
If the UDT is used in a table, the UDT cannot be dropped until the table column is dropped.
InvalidRequest: Error from server: code=2200 [Invalid query]
message="Cannot drop user type cycling.basic_info as it is still
used by table cycling.cyclist_stats"
-
If the UDT is used in a column that has a secondary index, the UDT cannot be dropped until the index is dropped.
InvalidRequest: Error from server: code=2200 [Invalid query]
message="Cannot drop column races because it has dependent secondary indexes (cyclist_races_races_idx)"
-
If the UDT is used in a non-frozen column, the table column cannot be dropped with an
ALTER TABLE
command.
InvalidRequest: Error from server: code=2200 [Invalid query]
message="Cannot drop non-frozen column basics of user type basic_info"
Examples
The following ordered steps can be used to drop a UDT:
Drop a UDT that is used in a table:
-
Drop an index that uses the type, if required.
DROP INDEX IF EXISTS cycling.races_idx;
-
Drop a table column that uses the type.
ALTER TABLE cycling.cyclist_races DROP races;
-
Drop the table that uses the type, if the first two steps do not work.
DROP TABLE IF EXISTS cycling.cyclist_races;
-
Drop the type.
DROP TYPE IF EXISTS cycling.race;
Drop a UDT that is not used in a table:
-
Drop the type.
DROP TYPE IF EXISTS cycling.basic_info;