Version:

Alter TableΒΆ

Apply various modifications to a table, view, or collection. The available modifications include the following:

Create or delete an index on a particular column. This can speed up certain operations when using expressions containing equality or relational operators on indexed columns. This only applies to tables.

Set the time-to-live (TTL). This can be applied to tables, views, or collections. When applied to collections, every contained table & view that is not protected will have its TTL set to the given value.

Set the global access mode (i.e. locking) for a table. The mode can be set to 'no_access', 'read_only', 'write_only' or 'read_write'.

Change the protection mode to prevent or allow automatic expiration. This can be applied to tables, views, and collections.

Allow homogeneous tables within a collection.

Manage a table's columns--a column can be added, removed, or have its type and properties modified.

Set or unset compression for a column.

Input Parameter Description

Name Type Description
table_name string Table on which the operation will be performed. Must be an existing table, view, or collection.
action string

Modification operation to be applied

Supported Values Description
allow_homogeneous_tables Sets whether homogeneous tables are allowed in the given collection. This action is only valid if input parameter table_name is a collection. The input parameter value must be either 'true' or 'false'.
create_index Creates an index on the column name specified in input parameter value. If this column is already indexed, an error will be returned.
delete_index Deletes an existing index on the column name specified in input parameter value. If this column does not have indexing turned on, an error will be returned.
move_to_collection Moves a table into a collection input parameter value.
protected Sets whether the given input parameter table_name should be protected or not. The input parameter value must be either 'true' or 'false'.
rename_table Renames a table, view or collection to input parameter value. Has the same naming restrictions as tables.
ttl Sets the TTL of the table, view, or collection specified in input parameter table_name.
add_column Adds the column specified in input parameter value to the table specified in input parameter table_name. Use column_type and column_properties in input parameter options to set the column's type and properties, respectively.
change_column Changes type and properties of the column specified in input parameter value. Use column_type and column_properties in input parameter options to set the column's type and properties, respectively.
set_column_compression Modifies the compression setting on the column specified in input parameter value.
delete_column Deletes the column specified in input parameter value from the table specified in input parameter table_name.
create_foreign_key Creates a foreign key using the format 'source_column references target_table(primary_key_column) [ as <foreign_key_name> ]'.
delete_foreign_key Deletes a foreign key. The input parameter value should be the <foreign_key_name> specified when creating the key or the complete string used to define it.
set_global_access_mode Sets the global access mode (i.e. locking) for the table specified in input parameter table_name. Specify the access mode in input parameter value. Valid modes are 'no_access', 'read_only', 'write_only' and 'read_write'.
value string The value of the modification. May be a column name, 'true' or 'false', a TTL, or the global access mode depending on input parameter action.
options map of string to strings

Optional parameters. Default value is an empty map ( {} ).

Supported Parameters (keys) Parameter Description
column_default_value When adding a column, set a default value for existing records.
column_properties When adding or changing a column, set the column properties (strings, separated by a comma: data, store_only, text_search, char8, int8 etc).
column_type When adding or changing a column, set the column type (strings, separated by a comma: int, double, string, null etc).
compression_type

When setting column compression (set_column_compression for input parameter action), compression type to use: none (to use no compression) or a valid compression type. Default value is 'snappy'. The allowed values are:

  • none
  • snappy
  • lz4
  • lz4hc
copy_values_from_column When adding or changing a column, enter a column name from the same table being altered to use as a source for the column being added/changed; values will be copied from this source column into the new/modified column.
rename_column When changing a column, specify new column name.
validate_change_column

When changing a column, validate the change before applying it. If true, then validate all values. A value too large (or too long) for the new type will prevent any change. If false, then when a value is too large or long, it will be truncated. Default value is 'true'.

Supported Values Description
true true
false false

Output Parameter Description

Name Type Description
table_name string Table on which the operation was performed.
action string Modification operation that was performed.
value string The value of the modification that was performed.
type_id string return the type_id (when changing a table, a new type may be created)
type_definition string return the type_definition (when changing a table, a new type may be created)
properties map of string to arrays of strings return the type properties (when changing a table, a new type may be created)
label string return the type label (when changing a table, a new type may be created)