Modify Table Definitions

ALTER TABLE ADD field
ALTER TABLE DROP field

Use ALTER TABLE statements to either add new fields to a table definition, or delete a currently existing field definition.

You cannot modify an existing field directly. Instead, you must delete the field, then add the field back using the new definition. Note that this will cause all existing data associated with the current field to be deleted.

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.