Database Reference
In-Depth Information
Cassandra 3 has plans to make UDTs as free as collections. So this is basically fu-
ture proofing.
You can have collections within a UDT. Also, obviously, creating a UDT of a type that is
provided by Cassandra out of the box will throw an error. Ideally, avoid all reserved
keywords as a rule of thumb.
Altering a custom type
You cannot drop an attribute but you can practically do everything that you can do while
altering a table. You can change type name, change attributes within the type's type,
change the attributes' name, and append a new attribute.
Here are the patterns followed by an example:
ALTER TYPE old_type_name RENAME TO new_type_name;
At the time of writing, the preceding code was failing in Cassandra 2.1.
# Rename a type attribute
ALTER TYPE type_name RENAME old_column_name TO
new_column_name;
ALTER TYPE address RENAME postal_code TO zipcode;
# Change a type attribute's type
ALTER TYPE type_name ALTER column_name TYPE new_type;
ALTER TYPE address ALTER country TYPE blob;
# Add a new attribute to the type
ALTER TYPE type_name ADD new_column column_type;
ALTER TYPE address ADD default_address Boolean;
# Final type
DESC TYPE address
CREATE TYPE address (
address text,
country blob,
zipcode text,
preference int,
Search WWH ::




Custom Search