Entering content frame

DROP Definition (drop_definition) 

You can delete table properties by specifying a DROP definition in the ALTER TABLE statement.

Syntax

<drop_definition> ::= DROP <column_name>,... [<cascade_option>] [RELEASE SPACE]
| DROP (<column_name>,...) [<cascade_option>] [RELEASE SPACE]
| DROP CONSTRAINT <constraint_name> | DROP PRIMARY KEY

column_name, cascade_option, constraint_name

Explanation

Dropping a column: DROP <column_name>

Each column name must be a column of the table identified by the ALTER TABLE statement. The column must be neither a key column nor a foreign key column of a referential CONSTRAINT definition of the table.

The columns are marked as dropped in the metadata of the table. A DROP definition does not automatically reduce the memory requirements of the underlying table. RELEASE SPACE forces the column values of the dropped columns to be dropped in every row in the table. With large tables, in particular, this may take more time, since extensive copy operations have to be carried out.

Any privileges and comments for the columns to be dropped are also dropped.

If one of the columns to be dropped occurs as a selected column in a view definition, the specified column in the view table is dropped.
If this view table is used in the FROM clause of another view table, the described procedure is applied recursively to this view table.

·        If one of the columns to be dropped occurs in the QUERY specification of a view definition and if no CASCADE condition is specified or if the CASCADE condition CASCADE is specified in the DROP definition, the view definition is dropped with all the view tables, privileges, and synonyms that depend on it.

·        If one of the columns to be dropped occurs in the QUERY specification of a view definition, and if  the CASCADE condition RESTRICT is specified in the DROP definition, the ALTER TABLE statement fails.

Existing indexes referring to columns to be dropped are also dropped. The storage space for the dropped indexes is released.

All CONSTRAINT definitions that contain one of the dropped columns are dropped.

Dropping a constraint: DROP CONSTRAINT <constraint_name>

The constraint name must identify a CONSTRAINT definition in the table. This definition is then deleted from the metadata of the table.

Dropping a key: DROP PRIMARY KEY

·        The table must have a key defined by the user.

·        The table must not contain more than 1023 columns (technical specifications).

·        The maximum permissible length of a row must not exceed 8088 bytes.

·        The key columns must not be a referenced column of a referential CONSTRAINT definition.

The key is replaced by the key column SYSKEY generated by the database system. With large tables, in particular, this may take more time, since extensive copy operations have to be carried out.

 

Leaving content frame