You can modify data types and properties of table columns by specifying a MODIFY definition in the
ALTER TABLE statement.Syntax
<modify_definition> ::= MODIFY (<column_name> [<data_type>] [<column_attributes>]...)
column_name, data_type, column_attributesThe parentheses are not necessary if the MODIFY definition only contains one column name.
Explanation
Each column name must be a column of the base table specified in the ALTER TABLE statement.
Column attributes
Only the following column attributes are allowed:
Data types
If a DEFAULT specification is not specified and if a DEFAULT specification is defined for the corresponding column, it must be compatible with the data type.
Data type CHAR(n), VARCHAR(n): the corresponding column must have the data type
CHAR(n), VARCHAR(n), DATE, TIME, or TIMESTAMP. In this case, the table must not contain a row in which the column has a value with a length greater than n.Data type DATE: the corresponding column must have the data type CHAR(n), VARCHAR(n), or
DATE. This column must contain a date value in any of the date formats supported by the database system in all rows of the table.Data type FIXED(n,m): the corresponding column must have the data type
FIXED(n,m), FLOAT, INT, or SMALLINT. In this case, the table must not contain a row in which the column has a value with more than (n - m) integral or m fractional digits.Data type FLOAT(n): the corresponding column must have the data type FIXED(n,m), FLOAT(n), INT, or SMALLINT.
Data type INT: the corresponding column must have the data type FIXED(n,m), FLOAT(n), INT, or SMALLINT. In this case, the table must only contain rows in which this column has integral values in the range between -2147483648 and 2147483647.
Data type SMALLINT: the corresponding column must have the data type FIXED(n,m), FLOAT(n), INT, or SMALLINT. In this case, the table must only contain rows in which this column has integral values in the range between -32768 and 32767.
Data type TIME: the corresponding column must have the data type CHAR(n), VARCHAR(n), or
TIME. This column must contain a time value in any of the time formats supported by the database system in all rows of the table.Data type TIMESTAMP: the corresponding column must have the data type CHAR(n), VARCHAR(n), or
TIMESTAMP. This column must contain a timestamp value in any of the timestamp formats supported by the database system in all rows of the table.Column attribute NULL: a
NULL value can be entered in the corresponding column with a subsequent INSERT or UPDATE statement.If one of the columns identified by
column name is contained in a search condition for the table, this column must also define a legal search condition after the data type has been modified.Others
Depending on the type of modification, the MODIFY definition may result in the table having to be recopied and/or indexes rebuilt. In such a case, the runtime will be considerably long.
If a table is recopied and the table contains columns marked as deleted, then these columns are removed from the catalog and from the table rows, thus reducing the space requirements of the table.