Modify Table Definitions

Use ALTER TABLE statements to either add new fields to a table definition, or delete a currently existing field definition. You can also use an ALTER TABLE statement to change the default Time-to-Live (TTL) value for a table.

ALTER TABLE ADD field

To add a field to an existing table, use the ADD statement:

ALTER TABLE table-name (ADD field-definition)

See Field Definitions for a description of what should appear in field-definitions, above. For example:

ALTER TABLE Users (ADD age INTEGER)

You can also add fields to nested records. For example, if you have the following table definition:

CREATE TABLE u (id INTEGER,
                info record(firstName String)),
                PRIMARY KEY(id)) 

then you can add a field to the nested record by using dot notation to identify the nested table, like this:

ALTER TABLE u(ADD info.lastName STRING)

ALTER TABLE DROP field

To delete a field from an existing table, use the DROP statement:

ALTER TABLE table-name (DROP field-name)

For example, to drop the age field from the Users table:

ALTER TABLE Users (DROP age)

Note that you cannot drop a field if it is the primary key, or if it participates in an index.

ALTER TABLE USING TTL

To change the default Time-to-Live (TTL) value for an existing table, use the USING TTL statement:

ALTER TABLE table-name USING TTL ttl

For example:

ALTER TABLE Users USING TTL 4 days

For more information on the USING TTL statement, see USING TTL.