You can define additional table properties by specifying an ADD definition in the ALTER TABLE statement.
<add_definition> ::= ADD <column_definition>,...
| ADD (<column_definition>,...)
| ADD <constraint_definition>
| ADD <referential_constraint_definition>
| ADD <key_definition>
column_definition, constraint_definition, key_definition, referential_constraint_definition
The following statement adds two columns to the customer table. The columns initially contain the NULL value in all rows.
ALTER TABLE customer ADD (phone_number FIXED (8), street CHAR (15))
The new columns can be used immediately.
You can specify column definitions to add these columns to the table specified in the ALTER TABLE statement. These specifications must not exceed the maximum number of columns allowed and the maximum length of a row.
The memory requirements for each column are increased by one character (for normal memory requirements, see Memory requirements of a column value as a function of the data type), if the length described is less than 31 characters and the column does not have the data type VARCHAR.
The newly defined columns contain the NULL value in all rows, if no default value has been specified for these columns using a DEFAULT specification. If the NULL value violates a CONSTRAINT definition of the table, the ALTER TABLE statement will fail.
When you add LONG columns, you cannot make a DEFAULT specification. If you want to define a default value for a LONG column, you can define the LONG column using the ADD definition and then use MODIFY Definition to define a default value for the definition.
In every other respect, specifying a column definition has the same effect as specifying a column definition in a CREATE TABLE statement.
· If view tables are defined for the specified table, and if alias names are defined for one of these view tables, and if the view tables reference the columns in the table with *, the ALTER TABLE statement will fail.
· If view tables are defined for the specified table, and if no alias names are defined, and if the view tables reference the columns in the table with *, this view table contains the columns added to the base table by the ADD definition.
All of the rows in the table must satisfy the condition defined by the search condition of the CONSTRAINT definition.
An integrity condition is defined for the table specified in the ALTER TABLE statement. The columns specified in the referential CONSTRAINT definition must be columns in the table.All of the rows in the table must satisfy the integrity condition defined by the referential CONSTRAINT definition.
A key is defined for the table specified in the ALTER TABLE statement. At execution time, the table must only contain the key column SYSKEY generated by the database system. The columns specified in the key definition must be columns in the table and must satisfy the key properties (none of the columns may contain NULL value, and no two rows in the table may have the same values in all columns of the key definition). The new key is stored in the metadata of the table. The key column SYSKEY is omitted. This is an extremely lengthy procedure for tables with a large number of rows, since extensive copy operations are carried out.
If a primary key is defined for the table specified in the ALTER TABLE statement, and the structure of this primary key matches the structure of an existing index exactly, then this index is deleted.