ADD definition 

You can define additional table properties by specifying an ADD definition in the ALTER TABLE statement.

Syntax

<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 (telephone FIXED (8), street CHAR (15))

The new columns can be used straight away.

Explanation

Adding a column definition: ADD <column_definition>

A domain name can only be specified in a column definition if the domain was defined without a DEFAULT specification.

You can extend the table specified in the ALTER TABLE statement to include these columns by specifying column definitions. 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.

None of the newly defined columns may have the data type LONG. The column names specified must differ from each other and must not be identical to the names existing columns in the table.

The new columns contain the NULL value in all rows. If the NULL value violates a CONSTRAINT definition of the table, the ALTER TABLE statement will fail.

In every other respect, specifying a column definition has the same effect as specifying a column definition in a CREATE TABLE statement.

Adding a CONSTANT definition: ADD <constant definition>

All of the rows in the table must satisfy the condition defined by the search condition of the CONSTRAINT definition.

Adding a referential CONSTRAINT definition: ADD <referential_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.

Adding a key definition: ADD <key 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.