ALTER TABLE statement
ALTER TABLE tableOwner 1 .tableName 1 | This option specifies the fully qualified name of the table to be changed. | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
OWNER tableOwner 2 | This option specifies the new owner of the table. | ||||||||||
NAME tableName 2 | This option specifies the new name of the table. | ||||||||||
DATABASE databaseName | This option specifies the new database for the table. | ||||||||||
TABLESPACE | This option specifies the new table space for the table. TABLESPACE parameter values
| ||||||||||
VALIDPROC procedureName | This option defines a new validation procedure. | ||||||||||
NOVALIDPROC | This option removes an existing validation procedure. | ||||||||||
AUDIT | This option specifies the audit procedure for the table. AUDIT parameter values
| ||||||||||
ALTER COLUMN columnName 1 (alterColumnSpecification) | Modifies a column according to the specifications in alterColumnSpecification (see alterColumnSpecification). | ||||||||||
DROP COLUMN columnName 2 | This option removes the columnName column from the table. | ||||||||||
ADD COLUMN columnName 3 position (addColumnSpecification) | Adds a new column according to the specifications in addColumnSpecification (see addColumnSpecification). ADD COLUMN position parameter values
| ||||||||||
partitionParameters | For a description of the parameters used in partitionParameters, see partitionParameters. | ||||||||||
DATA CAPTURE | This option specifies whether additional information is added to the logging of SQL commands. DATA CAPTURE parameter values
| ||||||||||
VOLATILE | This option specifies whether Db2 should use index access to the table whenever possible. The following table lists valid values for the VOLATILE parameter. VOLATILE parameter values
| ||||||||||
DROPRESTRICT | This option indicates whether to restrict a table from being dropped. DROPRESTRICT parameter values
| ||||||||||
ALTER PERIOD BUSINESS_TIME(columnName 5 , columnName 6) | This option modifies the columns that are used as the beginning and end of the BUSINESS_TIME period. columnName5 identifies the column that begins the time period. columnName6 identifies the column that ends the time period. BUSINESS_TIME parameter values (valid for Db2 Version 12.1 and later)
| ||||||||||
ADD PERIOD BUSINESS_TIME(columnName 7 , columnName 8) | This option specifies to add a BUSINESS_TIME period to the table. columnName 7 identifies the column that begins the time period. columnName 8 identifies the column that ends the time period. The BUSINESS_TIME parameter values table lists valid values for the BUSINESS_TIME parameter (valid for Db2 Version 12.1 and later). |
ALTER Table statement (page 2)
DROP PERIOD BUSINESS_TIME | This option removes the BUSINESS_TIME period from the table. | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
ALTER PERIOD SYSTEM_TIME(columnName 9 , columnName 10) | Modifies the columns that are used as the beginning and end of the SYSTEM_TIME period. | ||||||||||
ADD PERIOD SYSTEM_TIME(columnName 11 , columnName 12) | This option specifies to add a SYSTEM_TIME period to the table. columnName 11 identifies the column that begins the time period. columnName 12 identifies the column that ends the time period. | ||||||||||
DROP PERIOD SYSTEM_TIME | This option removes the SYSTEM_TIME period from the table. | ||||||||||
CONTROL | This option specifies which access controls are activated on the table. CONTROL parameter values
| ||||||||||
APPEND | This option specifies whether to use append processing for the table. With append processing, Db2 attempts to place table rows in accordance with the value in the rows’ cluster key columns when inserting or loading data. APPEND parameter values
| ||||||||||
KEY LABEL keyLabelName | This option specifies the name of the encryption key for the table. | ||||||||||
NO KEY LABEL | This option removes the associated encryption key from the table. | ||||||||||
ARCHIVING TABLE(tableOwner.tableName) | This option associates an archive table to an archive-enabled table. ARCHIVING TABLE parameter values
| ||||||||||
VERSIONING TABLE(tableOwner.tableName) | This option adds a history table. VERSIONING TABLE parameter values
| ||||||||||
MQT | This option specifies whether the table is a materialized query table. MQT parameter values
| ||||||||||
MQTParameters | This option specifies the parameters for the MQT (see MQTParameters). | ||||||||||
alterTableOptions | Provides additional options for tables (see alterTableOptions). |
alterColumnSpecification
alterColumnSpecification includes the following parameters:
builtInDataType | This option defines the column as the specified Db2 data type. See builtinDataType. For information about valid data types, see the IBM documentation. | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
TYPESCHEMA dataTypeSchema | This option specifies the schema type of the column. | ||||||||||||||||||||||
TYPENAME dataTypeName | This option specifies the distinct type of the column. | ||||||||||||||||||||||
FOR subtype DATA | (persistent and global temporary tables) For character (CHAR), varying-length character (VARCHAR), and character large object (CLOB) columns, defines the character subtype subtype values
| ||||||||||||||||||||||
FIELDPROC procedureName (constant, ...) | This option defines a field procedure exit routine for the defined column. | ||||||||||||||||||||||
NOFIELDPROC | This option specifies to remove an existing field procedure exit routine. | ||||||||||||||||||||||
NOFIELDPROCPARMS | This option indicates to keep the same field procedure exit routine, but not to specify a list of parameters. | ||||||||||||||||||||||
INLINE LENGTH integer | This option specifies the length for an inline LOB column. A value of 0 indicates that the column is not a LOB column, or that the LOB column does not have a length. | ||||||||||||||||||||||
nullParameters | Provides additional options for null parameters (see nullParameters). | ||||||||||||||||||||||
IDENTITY | This option indicates whether the table includes an identity column. Each table can have one identity column. IDENTITY parameter values
If the table includes an identity column, the parameters in Identity column parameter values describe the column. Identity column parameter values
| ||||||||||||||||||||||
ROWCHANGE | This option indicates whether to generate the time stamp of the most recent change to a row in a column. The data type must be TIMESTAMP, and the null parameter must be NOT NULL. ROWCHANGE parameter values
| ||||||||||||||||||||||
MOVE BEFORE columnName | This option moves the column before columnName (which must be the current name of an existing column). For example, if the table X.TAB contains the columns COL1, COL2, and COL3, then the following CDL statement would result in a column order of COL2, COLX, and COL3. ALTER TABLE X.TAB ALTER COLUMN COL1 (NAME COLX) ALTER COLUMN COL2 (MOVE BEFORE COL1) ALTER TABLE X.TAB ADD COLUMN COLA BEFORE COL1 (col_spec...) ALTER COLUMN COL2 (MOVE BEFORE COLA) | ||||||||||||||||||||||
MOVE AFTER columnName | This option moves the column after columnName (which must be the current name of an existing column). | ||||||||||||||||||||||
NAME columnName | This option specifies the new name of the column. | ||||||||||||||||||||||
HIDDEN | This option indicates whether the column can be 'hidden' or excluded from the results of a SELECT * SQL statement. The following table lists valid values for the HIDDEN parameter. HIDDEN parameter values
|
builtInDataType
For information about valid data types, see the IBM documentation.
builtInDataType page 2
For information about valid data types, see the IBM documentation.
nullParameters
nullParameters uses the following parameters.
NOT NULL | This option specifies that the column cannot contain any null values. NOT NULL parameter values
| ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
NULL | This option specifies that the column can contain null values. Any column added to a global temporary table must have a default value of null. NULL parameter values
|
addColumnSpecification
addColumnSpecification includes the following parameters.
For a description of these parameters, see alterColumnSpecification.
partitionParameters
partitionParameters contains the following parameters.
NUMPARTS number | This option specifies the new number of partitions for the table. NUMPARTS=0 specifies a nonpartitioned table. | ||||||
---|---|---|---|---|---|---|---|
ALTER PART partitionNumber 1 | For a partitioned table, alters partitionNumber 1 according to the replacement key limit list for the table and the new number for the partitionNumber 2 partition of the table. To alter parameters for a partitioned table, the partitionNumber 1 value must not be zero. For example, the following example changes the value for the VALUES attribute for the first partition of a partitioned table to 4536. ALTER TABLE ... ALTER PART 1 VALUES (4536) ALTER PART parameter values
| ||||||
ADD PART BEFORE partitionNumber VALUES (constant, ...) | For a partitioned table, adds a new partition according to the replacement key limit list for the table. The partition is added before the specified partitionNumber. | ||||||
ADD PART AFTER partitionNumber VALUES (constant, ...) | For a partitioned table, adds a new partition according to the replacement key limit list for the table. The partition is added after the specified partitionNumber. | ||||||
DROP PART partitionNumber | For a partitioned table, drops the specified partition. | ||||||
KEYCOLUMNS (columnName order, ...) | This option specifies the replacement column list that defines the key for this table. KEYCOLUMNS order parameter values
| ||||||
TCPART | This option indicates whether the partitioned table uses table-controlled partitioning. TCPART parameter values
|
MQTParameters
MQTParameters uses the following parameters for a materialized query table.
PATH | This option specifies the path for the materialized query table. PATH parameter values
| ||||||
---|---|---|---|---|---|---|---|
TEXT( AS SELECT( fullSelect ) ) | This option defines the fullselect component of the SQL statement that is used to create the materialized query table. | ||||||
MAINTAINEDBY | This option specifies whether the system or the user maintains data in the materialized query table. MAINTAINEDBY parameter values
| ||||||
QUERYOPT | This option specifies whether the materialized query table can be used to optimize queries. QUERYOPT parameter values
|
alterTableOptions
alterTableOptions contains the following parameters:
EDITPROC procedureName | This option defines a new edit procedure. EDITPROC parameter values
| ||||||||
---|---|---|---|---|---|---|---|---|---|
NOEDITPROC | This option removes an existing edit procedure. | ||||||||
PRIMARYKEY (columnName, ...) | Creates a new primary key for the table, consisting of the columns that are specified in the column name list. This primary key definition either replaces an existing primary key or creates one if one does not already exist. | ||||||||
NOPRIMARYKEY | This option removes a primary key definition from a table where one exists. | ||||||||
COMMENT 'string' | This option defines a new comment for the table. | ||||||||
NOCOMMENT | This option removes an existing comment. | ||||||||
LABEL 'string' | This option defines a new label for the table. | ||||||||
NOLABEL | This option removes an existing label. | ||||||||
COLCOMMENT columnName 'string' | This option defines a comment 'string' on columnName. | ||||||||
NOCOLCOMMENT columnName | This option removes an existing column comment from columnName. | ||||||||
COLLABEL columnName 'string' | This option defines a label 'string' on columnName. | ||||||||
NOCOLLABEL columnName | This option removes an existing column label from columnName. | ||||||||
OBID number | This option defines the object identifier for a table in a read-only shared database. | ||||||||
CCSID | (global temporary tables) This option specifies the new encoding scheme of the table CCSID parameter values
|