Alter a UDT

Use the ALTER TYPE command to add fields to a user-defined type (UDT) or to rename an existing field in a UDT.

This command requires a keyspace, table, and UDT.

Limitations

You cannot modify UDTs that are used in primary keys or indexed columns.

You cannot change the field type for any UDT. If you need to change the field type, you must create a new UDT with the correct type, add the new type to your table definitions, and reinsert all of the data to the new column. Then, you can drop the old UDT.

Add a user-defined data type (UDT)

Add a middlename field of type text to the user-defined type cycling.fullname.

ALTER TYPE cycling.fullname
ADD middlename text;

The ALTER TYPE command adds the field to the type.

Check that the UDT is created

Verify the changes, use the DESC TYPE command:

DESCRIBE TYPE cycling.fullname;
Results

The middlename column appears in the type definition.

CREATE TYPE cycling.fullname (
    firstname text,
    lastname text
);

Rename an existing UDT field

To change the name of an existing field, use RENAME.

ALTER TYPE cycling.fullname
RENAME middlename TO middle
  AND lastname TO last
  AND firstname TO first;

Check the results

Verify the changes.

DESCRIBE TYPE cycling.fullname;
Results

The renamed fields appear in the type definition.

CREATE TYPE cycling.fullname (
    firstname text,
    lastname text,
    middlename text
);

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2025 DataStax, an IBM Company | 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: +1 (650) 389-6000, info@datastax.com