Summary
The CREATE TABLE
command creates a new table within Connect’s ‘delta’ schema and any available custom schemas.
Syntax
create [unlogged] table [if not exists] <schema name>.<table name> (<column name> <type> [,primary key (column_name1 [, column_name2..n])] [,foreign key (column_name1 [, column_name2..n]) references <schema name>.<table name> (column_name1 [, column_name2..n])]); |
Parameters
<td<schema name><td”>(Optional) Connect supports both primary keys on a single column and composite primary keys.
Parameter | Description |
---|---|
[unlogged] | (Optional) Unlogged tables may improve the performance of INSERT, UPDATE, and DELETE operations run against the table. Xactly recommends using unlogged tables for transient or temporary data sets only. The risk of data loss in the event of system failure is present when using unlogged tables. By default, custom tables are logging enabled. |
(Required) Connect allows users to create tables in the ‘delta’ schema and any custom schemas found in your environment. Developers may not create, alter, or drop tables in the ‘xactly’, ‘xdms’, and ‘staging’ schemas. | |
<table name> | (Required) A unique string descriptor for the table. Table names within a given schema must be unique. |
[if not exists] | (Optional) Instructs Connect to create the table only if it is not already found in the system. The parameter can be useful in pipeline steps where you want to create a table only if it is not present. |
<column name> | (Required) Column names within a table must be unique. |
<type> | (Required) Connect supports the following column data types:
|
[,primary key (column_name1 [, column_name2..n]] | (Optional) Connect supports both single column and composite primary key constraints. |
[,foreign key (column_name1 [, column_name2..n]) references <schema name>.<table name> (column_name1 [, column_name2..n])] |
(Optional) Connect supports foreign key constraints. |
Details
xSQL tables are similar to table objects found in traditional relational databases such as Oracle, MySQL, and others. Tables store data in rows and columns, with data types for each column in a table are defined when a table is created.
After creating a table, you can manipulate data in the table using the INSERT
, UPDATE
, and DELETE
statements and query the table using the SELECT
statement.
Refer to INSERT
to create a table based on the result set of a SELECT query.
Examples
create table delta.my_first_table (col1 varchar(256), col2 integer, col3 instant, col4 decimal);
create unlogged table if not exists delta.raw_sales_transactions (order_number string primary key, line_number integer, invoice_date date, order_amount decimal);
create table delta.primary_key_example (col1 string(256), col2 string(28), col3 zoned_date_time, col4 string(256), primary key(col1));
create table delta.foreign_key_example (column_1 string(256), column_2 string(100), column_3 decimal(12,2), foreign key(column_1) references delta.primary_key_example(col1));