Was this helpful?
CREATE TABLE
Valid in: SQL, ESQL, OpenAPI, ODBC, JDBC, .NET
The CREATE TABLE statement creates a base table.
Note:  This statement has additional considerations when used in a distributed environment. For more information, see the Star User Guide.
The CREATE TABLE statement has the following format:
[EXEC SQL] CREATE TABLE table_name
              (column_specification {, column_specification }
              [WITH with_clause]
The CREATE TABLE...AS SELECT statement (which creates a table and load rows from another table) has the following format:
[EXEC SQL] CREATE TABLE table_name
              [(column_name {, column_name})] AS
                            subselect
                            {UNION [ALL]
                            subselect}
              [WITH with_clause]
table_name
Defines the name of the new table, which must be a valid object name (see Rules for Naming Objects).
column_specification
Defines the characteristics of the column, as described in Column Specification--Describe Column Characteristics.
AS
Causes the table that you create to be defined and populated by the subselect.
subselect
Specifies a SELECT clause, as described in Using CREATE TABLE...AS SELECT.
WITH with_clause
Specifies Enterprise Access product-specific options. For details,see your Enterprise Access product guide.For an overview of the Enterprise Access product WITH clause, see the chapter "OpenSQL Features."
The CREATE TABLE statement creates a new base table owned by the user who issues the statement. If you use the CREATE TABLE...AS syntax, then the table that you create is a subset of the columns and values in existing tables defined by the subselect.
To ensure application portability, follow every CREATE TABLE statement with a COMMIT statement.
Last modified date: 08/14/2024