ALTER TABLE
Modify existing table definitions.
Synopsis
Description
ALTER TABLE
changes the metadata definition of an existing table in the current database.
The table must be in the NOT READY
state, otherwise the command results in an error. A table is in NOT READY
state if it’s created with the CREATE TABLE SET NOT READY
option, and until the ALTER TABLE SET READY
command is performed on it.
Parameters
table_name
The name of an existing table to alter.
action
SET READY
This form finalizes the table’s schema and index set, and makes it accessible for DML operations. Any subsequent ALTER TABLE command will fail as the table transitions to the READY state.
ADD [ COLUMN ]
Adds a new column to the table, using the same syntax as in CREATE TABLE. The column name must be unique within the table and conform with the Identifiers Limitations.
column_name
The name of the added column.
data_type
Data type of the new column. For more information on the supported data types, refer to Data Types.
The rest of the parameters used in this command are described in the CREATE TABLE command.
Examples
Create a table as not ready and alter it to modify its definition:
This example creates a table and builds it gradually with ALTER TABLE
commands, and eventually finalizes it with SET READY
.
Note that the ALTER TABLE
command can only work as long as the parts table is defined as NOT READY
.
Compatibility
The ALTER TABLE
command conforms to the SQL standard, with exceptions listed below.
SET READY
is a Regatta extensionWITH
clause is a Regatta extension; storage parameters are not in the standard.