4. SQL Statements : CREATE TABLE
Share this page                  
Valid in: SQL, ESQL, OpenAPI, ODBC, JDBC, .NET
The CREATE TABLE statement creates a base table.
Note:  A Vector table cannot be created in either iidbdb or imadb (system databases).
This statement has the following format:
CREATE TABLE [IF NOT EXISTS] [schema.] table_name
       (column_specification {, column_specification })
       [table_constraint {, table_constraint}]
The CREATE TABLE...AS SELECT statement (which creates a table and loads rows from another table) has the following format:
CREATE TABLE table_name
        (column_name {, column_name}) AS
                      [WITH common_table_expressionsubselect
                      {UNION [ALL]
Creates the table if it does not exist and returns without error if the table already exists.
Note:  Use this option with caution. The table definition of a pre-existing table may differ with that of the CREATE TABLE IF NOT EXISTS statement.
Defines the name of the new table. It must be a valid object name.
Defines the characteristics of the column, as described in Column Specification.
Note:  For Vector tables, defaults, nullability, and identity columns work only for INSERT...VALUE, not INSERT SELECTs.
Specifies the table-level constraint as described in Table-level and Column-level Constraints.
Specifies WITH clause options separated by a comma. For details, see WITH Clause.
Important!  The WITH PARTITION= or WITH NOPARTITION clause is required. For details, see Partitioned Tables.