CREATE TABLE statement
The CREATE TABLE statement defines a new persistent table or global temporary table to the Db2 system.
CREATE TABLE statement (page 1)
CREATE TABLE tableOwner 1.tableName 2 | This option specifies the fully qualified name of the table to be created. | ||||||||
---|---|---|---|---|---|---|---|---|---|
SQLID SQLID | This option specifies the current SQLID. | ||||||||
COLUMNS (columnDefinition, ...) | This option specifies the column definitions for the table according to columnDefinition (see columnDefinition). | ||||||||
PERIOD BUSINESS_TIME(columnName 1, columnName 2) | This option specifies the BUSINESS_TIME period for the table. columnName 1 identifies the column that begins the time period. columnName 2 identifies the column that ends the time period. BUSINESS_TIME parameter values (valid for Db2 Version 12.1 and later)
| ||||||||
PERIOD SYSTEM_TIME(columnName 3, columnName 4) | This option specifies the SYSTEM_TIME period for the table. columnName 3 identifies the column that begins the time period. columnName 4 identifies the column that ends the time period. | ||||||||
VERSIONING_TABLE tableOwner 2.tableName 2 | This option specifies the name of the history table. | ||||||||
ARCHIVING_TABLE tableOwner 3.tableName 4 | This option specifies the name of the archive table. | ||||||||
CLONE | CLONE parameter values
| ||||||||
REFERENCETB tableOwner 5.tableName 6 | This option specifies the name of the table to which the clone table references. | ||||||||
MQT | This option specifies the materialized query table (MQT). MQT parameter values
| ||||||||
MQTParameters | This option specifies the parameters for the MQT (see MQTParameters). | ||||||||
DATABASE databaseName | This option specifies the database for the table. | ||||||||
TABLESPACE | This option specifies the new table space for the table. TABLESPACE parameter values
| ||||||||
TYPE | This option specifies the type of table to create. TYPE parameter values
| ||||||||
EDITPROC procedureName | This option specifies an edit procedure for the table. EDITPROC parameter values
| ||||||||
VALIDPROC procedureName | This option specifies a validation procedure for the table. | ||||||||
AUDIT | This option specifies the audit procedure for the table. AUDIT parameter values
| ||||||||
OBID integer | This option specifies the value of the internal identifier of a table (OBID) in a read-only shared database. | ||||||||
NUMPARTS number (PART number tablePartitionParameters) | This option defines the new number of partitions for the table. For a partitioned table, NUMPARTS defines the parameters for PART number according to tablePartitionParameters (see tablePartitionParameters). |
CREATE TABLE statement (page 2)
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. VOLATILE parameter values
| ||||||||
DROPRESTRICT | This option indicates whether to restrict a table from being dropped. DROPRESTRICT 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
| ||||||||
CCSID | (global temporary tables) This option specifies the new encoding scheme of the table. CCSID parameter values
| ||||||||
KEY LABEL keyLabelName | This option specifies the name of the encryption key for the table. | ||||||||
PRIMARYKEY (columnName, ...) | This option specifies the primary key definition for the table. | ||||||||
KEYCOLUMNS (columnName order, ...) | This option specifies the names of the partitioning key columns for the table. order values
| ||||||||
COMMENT 'string' | This option defines a comment for the table. | ||||||||
LABEL 'string' | This option defines a label for the table. | ||||||||
COLCOMMENT columnName 'string' | This option defines a comment 'string' on columnName. | ||||||||
COLLABEL columnName 'string' | This option defines a label 'string' on columnName. |
columnDefinition
columnDefinition uses the following parameters.
columnName | (persistent and global temporary tables) This option specifies the type of column. columnName values
| ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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 for the defined column. | ||||||||||||||||||||||
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 | 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 | 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
| ||||||||||||||||||||||
HIDDEN | Indicates whether the column can be 'hidden' or excluded from the results of a SELECT * SQL statement. HIDDEN parameter values
|
builtInDataType (page 1)
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 any null values. Any column added to a global temporary table must have a default value of null. NULL 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
|
tablePartitionParameters
tablePartitionParameters uses the following parameter:
VALUES (constant, ...) | This option specifies the limiting constants for this partition of the table. |
---|
Related topics