CREATE TABLE
Valid in: SQL, ESQL, OpenAPI, ODBC, JDBC, .NET
The CREATE TABLE statement creates a base table.
Notes:
• This statement has additional considerations when used in a distributed environment. For more information, see the Ingres Star User Guide.
• An X100 table cannot be created in either iidbdb or imadb (system databases).
The CREATE TABLE statement has the following format:
[EXEC SQL] CREATE TABLE [IF NOT EXISTS] [schema.] tablename
(column_specification {, column_specification }
[, [CONSTRAINT constraint_name] table_constraint
{, [CONSTRAINT constraint_name] table_constraint}])
[with_clause]
The CREATE TABLE...AS SELECT statement (which creates a table and loads rows from another table) has the following format:
[EXEC SQL] CREATE TABLE tablename
(column_name {, column_name}) AS
[WITH common_table_expression] subselect
{UNION [ALL]
subselect}
[with_clause]
IF NOT EXISTS
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 preexisting table may differ from that of the CREATE TABLE IF NOT EXISTS statement.
tablename
Defines the name of the new table, which must be a valid object name.
column_specification
Note: For Vector tables, defaults, nullability, and identity columns work only for INSERT...VALUE, not INSERT SELECTs.
table_constraint
with_clause
• LOCATION = (location_name {, location_name})
• [NO]JOURNALING
• [NO]DUPLICATES*
• PAGE_SIZE = n*
• SECURITY_AUDIT = (audit_opt {, audit_opt})
• SECURITY_AUDIT_KEY = (column)*
• NOPARTITION | PARTITION = ( partitioning-scheme )
• [NO]AUTOSTRUCT*
• COMPRESSION[= ([[NO]KEY] [,[NO]DATA])] | NOCOMPRESSION*
• ALLOCATION = n*
• EXTEND = n*
• PRIORITY = n*
• ENCRYPTION=AES128|AES192|AES256, [AESKEY=hex-aes-key,] PASSPHRASE='encryption-passphrase'
• STRUCTURE = X100 | X100_ROW
• [NO]MINMAX = [(column {, column})]. Valid for X100 only.
* Not valid for X100 tables.
• STRUCTURE = HASH | HEAP | ISAM | BTREE
• KEY = (column_name {, column_name})
• FILLFACTOR = n
• MINPAGES = n
• MAXPAGES = n
• LEAFFILL = n
• NONLEAFFILL = n
AS [WITH common_table_expression] subselect
(Valid in CREATE TABLE AS SELECT only.)
Note: Subselect cannot be used when creating a table in one or more raw locations—that is, CREATE TABLE raw_table AS SELECT... WITH LOCATION = (raw_loc).
Last modified date: 01/30/2023