Documentation — Commands reference

alter

alter table describes a table in the dictionary. Before the table is deployed you use it to prepare the deployment; afterwards almost every form is refused.

Add and drop columns

alter table TABLE_NAME add [column] COL_NAME COL_TYPE [, add [column] COL_NAME COL_TYPE ...];
alter table TABLE_NAME drop column COL_NAME;
  • Not deployed: the table must have been created empty or wide. A table created with a column list cannot be altered: recreate it with the new definition.
  • Deployed, narrow table: the column is added on every segment. The statement is refused if one partition has no available server.
  • Deployed, wide table: adding a column is refused. Declare all columns before the deployment.
  • A column of the hash key cannot be dropped from a deployed table.

Before the deployment

alter table TABLE_NAME set datacenter 'DC1';
alter table TABLE_NAME set hash key COL_1 [, COL_2 ...];
alter table TABLE_NAME set replicates 1 | 2 | 3;
alter table TABLE_NAME set rrpc N;
alter table TABLE_NAME set empty;
  • set datacenter: mandatory, there is no default. The name is between quotes. It can change as long as the table is not deployed.
  • set hash key: mandatory. The columns, in order, make the hash key (see Partitioning).
  • set replicates: number of copies, 1 by default.
  • set rrpc: for a wide table, how many rows per chunk are reserved when the chunks are built (1 to 999). Leave the default unless you know why.
  • set empty: removes all the columns of a table that is not deployed.

After a failure

alter table TABLE_NAME set segments up;

For a table with one copy, brings up the segments that were declared out of date after a crash and for which you recovered the data. A table with several copies is repaired with repair table.

Privilege

ALTER on the table (the owner has it).

← API  |  create →