User-defined type (UDT) overview

A user-defined type is a custom type that can store multiple values in one column. Typically, they are used to store multiple related values that are meant to be output together, such as the parts of a mailing address.

Collections and UDTs

Like collections, UDTs are a useful way to reduce the number of columns and tables required for your data model, but you must use them judiciously to avoid performance issues and suboptimal data models:

  • Prefer regular columns with native data types whenever possible. Only use UDTs if absolutely necessary.

  • Collection usage guidelines also apply to UDTs:

    • Use frozen UDTs where possible.

    • For non-frozen UDTs, don’t specify too many fields.

  • You can add fields to a UDT, but you cannot remove them.

  • Serialization and deserialization is limited with UDTs. Instead, perform serialization and desensitization of UDT data inside the application, and then store the data as a BLOB.

  • Avoid deeply-nested UDTs and collections of UDTs.

    You can nest UDTs inside other UDTs, and you can use UDTs as elements in collections, but these patterns aren’t recommended. Because UDTs contain their own subelements, it is much easier to overload collections with too many elements. This can degrade read/write performance and cause failed writes due to maximum mutation size limits.

UDT keyspace scope

The UDT is only available in the keyspace where it is created. You must define the UDT itself on the keyspace before using it in a table definition.

To create a UDT in a specific keyspace, use dot notation (KEYSPACE_NAME.UDT_NAME). If no keyspace is specified, the UDT is scoped to the current keyspace.

You can use UDTs only in CREATE TABLE or ALTER TABLE statements within the same keyspace where the UDT is defined. However, in SELECT, INSERT, UPDATE statements, you can use dot notation to reference UDTs in any keyspace.

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