DROP TYPE

Immediately and irreversibly removes a user-defined type (UDT). This includes the UDT specification in the keyspace and associated metadata.

If the UDT is in use by a table, index, or another type, the command fails in most cases. You must drop the dependent usage before dropping the type.

If you need to retain the data from UDT columns, take action to preserve the data before dropping the UDT column. For example, you could rewrite the data to one or more new columns, or you could export the data with DataStax Bulk Loader (DSBulk) to CSV or JSON format for external storage.

Frozen columns

There is no restriction on dropping UDTs in frozen columns.

UDTs in frozen columns are dropped without blocking the operation.

Non-frozen columns

You must drop the column, and then drop the UDT.

The following error occurs when attempting to drop a UDT that is in use by a column:

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"

However, ALTER TABLE cannot be used to drop a non-frozen column with a UDT. The following error occurs:

InvalidRequest: Error from server: code=2200 [Invalid query]
message="Cannot drop non-frozen column basics of user type basic_info"

Instead, you must drop the entire table before dropping the UDT. Take any necessary action to preserve your data, unless you no longer need the table.

Indexed columns

You must drop the index, and then drop the UDT.

The following error occurs when attempting to drop a UDT that is used in a column with a secondary index:

InvalidRequest: Error from server: code=2200 [Invalid query]
message="Cannot drop column races because it has dependent secondary indexes (cyclist_races_races_idx)"

Synopsis

DROP TYPE [ IF EXISTS ] [<keyspace_name>.]<type_name> ;
Legend
Syntax conventions Description

UPPERCASE

Literal keyword.

Lowercase

Not literal.

< >

Variable value. Replace with a user-defined value.

[]

Optional. Square brackets ([]) surround optional command arguments. Do not type the square brackets.

( )

Group. Parentheses ( ( ) ) identify a group to choose from. Do not type the parentheses.

|

Or. A vertical bar (|) separates alternative elements. Type any one of the elements. Do not type the vertical bar.

...

Repeatable. An ellipsis ( ... ) indicates that you can repeat the syntax element as often as required.

'<Literal string>'

Single quotation (') marks must surround literal strings in CQL statements. Use single quotation marks to preserve upper case.

{ <key> : <value> }

Map collection. Braces ({ }) enclose map collections or key value pairs. A colon separates the key and the value.

<<datatype1>,<datatype2>>

Set, list, map, or tuple. Angle brackets ( < > ) enclose data types in a set, list, map, or tuple. Separate the data types with a comma.

<cql_statement>;

End CQL statement. A semicolon (;) terminates all CQL statements.

[--]

Separate the command line options from the command arguments with two hyphens ( -- ). This syntax is useful when arguments might be mistaken for command line options.

' <<schema\> ... </schema\>> '

Search CQL only: Single quotation marks (') surround an entire XML schema declaration.

@<xml_entity>='<xml_entity_type>'

Search CQL only: Identify the entity and literal value to overwrite the XML element in the schema and solrConfig files.

Parameters

Parameter Description Default

IF EXISTS

Optional. Only drop the type if it exists. If the type does not exist, no error is thrown.

If omitted, the command fails and throws an error if there is no type with the specified name in the keyspace.

keyspace_name

Optional. Name of the keyspace that contains the type to drop.

If not specified, the current keyspace is used.

type_name

Name of the type to drop.

Examples

  1. If needed, prepare to drop the UDT:

    • Drop an index that uses the type:

      DROP INDEX IF EXISTS cycling.races_idx;
    • Drop a column that uses the type:

      ALTER TABLE cycling.cyclist_races
        DROP races;
    • Drop an entire table that uses the type, if the UDT usage prevents dropping the column:

      DROP TABLE IF EXISTS cycling.cyclist_races;
  2. Drop the type:

    DROP TYPE IF EXISTS cycling.race;

Was this helpful?

Give Feedback

How can we improve the documentation?

© Copyright IBM Corporation 2026 | Privacy policy | Terms of use |  Manage Privacy Choices

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: Contact IBM