sys.tables system catalog table.
For information on other database components, see the pages on Databases, Schemas, Views, and Indexes.
CREATE TABLE
Creates a new table in the current database. The table name must be distinct from the name of any existing tables in the database unless theREPLACE keyword is specified. To use REPLACE in the CREATE TABLE statement, you must have DELETE privileges.
By default, columns are nullable unless otherwise specified.
For faster query results, you can define one for the table, which must be a timestamp, date, or time column, with a specified bucket resolution. Tables with a specified TimeKey can perform query operations faster, especially if they involve time filtering.
You can specify a Clustering Key composed of one or more fixed-length columns. Designating columns as cluster keys that are frequently referenced in queries can greatly improve performance.
For details about defining TimeKeys and clustering indexes, see TimeKeys and Clustering Keys.
See the Data Types section for table-supported data types.
Required Privileges: You must have the CREATE TABLE privilege for the current database.
For examples, see CREATE TABLE SQL Statement Examples.
SQL
| Parameter | Type | Description |
|---|---|---|
table_name | string | A unique identifier for the table. table_name must be distinct from the name of any existing tables in the database unless the REPLACE keyword is specified. |
query | string | A SELECT query used to load data into the newly created table. For details, see CREATE TABLE AS SELECT . |
Column Definition (<column_definition>)
The parameters listed here are required for defining each column in a table.
| Parameter | Type | Description |
|---|---|---|
column_name | string | An identifier for a column to be included in the newly created table. |
data_type | string | The data type of a specified column. For a list of supported data, see Data Types. |
Clustering Key and Index Definition (<clustering_definition>)
The parameters listed here are required for defining a Clustering Key or clustering indexes on a table.
For details about how to apply clustering columns, see Clustering Key.
SQL
| Parameter | Type | Description |
|---|---|---|
key_name | string | An identifier for the Clustering Key. |
ck_col1, ck_col2 [, ...] | string | A series of specific columns comprising the Clustering Key. Clustering Key columns must not be nullable. Specify NOT NULL in the column definition for the respective columns. For details, see Column Definition.No limit exists on the number of columns for the Clustering Key. |
index_name | string | Optional. An identifier for a clustering index. You must include the definition of columns that comprise the index using the idx_col1, idx_col2 [, ...] parameter. |
idx_col1, idx_col2 [, ...] | string | Optional. A series of specific columns comprising a clustering index. You can apply clustering indexes only to columns included in the Clustering Key. Specify any number of columns in any specified order. You must include the identifier for the index using the index_name parameter. |
TimeKey Definition (<timekey_definition>)
This syntax example is for a single TimeKey column, which can be included in the column definition of a CREATE TABLE statement. For the full syntax, see CREATE TABLE.
For details about using TimeKeys, see TimeKeys.
SQL
| Parameter | Type | Description |
|---|---|---|
column_name | string | An identifier for the column. |
data_type | string | Optional. The data type of the column. For the TimeKey column, this column should be DATE or TIMESTAMP type. The TimeKey column can also support INT or BIGINT type, but these data types do not use a bucket_value argument. |
bucket_granularity | numeric | The granularity of the TimeKey column, based on the specified TIME type in bucket_value. |
bucket_value | string | The TIME type to parse the TimeKey column. Supported values include: [ DAY, HOUR, MINUTE, SECOND ]For example, BUCKET(1, DAY) sets the time-bucket granularity to a fixed width of one day. |
Column Constraint (<column_constraint>)
The parameters listed here include constraints and other configurations for individual columns. For best performance, one column with date or time data in each table should be defined as the TIME KEY with a specified bucket_value.
For details about TimeKey columns, see TimeKeys.
| Parameter | Type | Description |
|---|---|---|
expression | data type of the column | If you specify this parameter as a constraint, the parameter sets the default value for the column. The value can be a literal or a constant, deterministic expression. Default expressions cannot use non-deterministic functions such as RAND(). The system evaluates the expression at the time of table creation and stores the resulting value. If the expression result does not match the column data type, the system automatically attempts type coercion to convert it.Literals Usage — The value can be a literal enclosed in quotes or an unquoted numeric literal. For example, this CREATE TABLE SQL statement includes a default value for its UUID column.CREATE TABLE example_table ( col1 UUID NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000' );The supported geospatial data types POINT, LINESTRING, and POLYGON require WKT formatting. For formatting examples, see the Well-known text representation of geometry. Expressions Usage — The value can also be an expression that evaluates to a constant, such as an arithmetic operation or a function execution. For example, this CREATE TABLE statement uses two default expressions. The column col1 uses a math equation that evaluates to 104. The column col2 concatenates two strings using the CONCAT function to create the new string 'HEYYOU'.CREATE TABLE example_table ( col1 INT DEFAULT 4 + (5 * 20), col2 VARCHAR DEFAULT CONCAT('HEY', 'YOU') ); |
comment | string | An optional comment for the column. |
compression_value | numeric | An integer value of either 1, 2 or 4 is used to define the storage of COMPRESSION GDC. The compression of the values is defined as follows: - A compression_value of 1 can hold up to 255 unique values.- A compression_value of 2 can hold up to 65535 unique values.- A compression_value of 4 can hold millions of unique values. For tuple columns, compression is specified for each tuple value rather than with other constraints. The example here defines a tuple column with GDC compression only for the first inner VARCHAR value.my_tuple TUPLE<<INT, VARCHAR(255) COMPRESSION GDC(1), VARCHAR(255)>>It is not recommended to use compression on a column that will contain more than one million unique values. |
schema_name | string | Fully qualified column name or a column name if you specify a column in the same table. If EXISTING is specified as a compression constraint, the compression GDC reuses the system lookup table for the schema_name column, rather than creating a new one. The existing column must be in the same database as the new column.schema_name should include the schema, table, and column names, each separated by periods and enclosed in double-quotation marks, for example: "schema_name"."table_name"."column_name"If an existing column is specified, any new column that uses the existing column’s system lookup table must be deleted before the existing column can be deleted. |
compression_scheme | string | The type of compression used for the column. Supported values include: [ COMPRESSION NONE | COMPRESSION ZSTD | COMPRESSION DYNAMIC ]If no compression setting is specified, the compression defaults to COMPRESSION DYNAMIC for fixed-length columns and COMPRESSION NONE for variable-length columns.COMPRESSION ZSTD applies to VARCHAR columns as well as other data types. For the COMPRESSION DYNAMIC setting, the System applies LZ4 compression only if the column data is dynamically determined to be compressible. For fixed-length columns, COMPRESSION DYNAMIC applies delta-delta compression. For details about Ocient-supported compression schemes, see Table Compression Options. |
Create Option (<create_option>)
The parameters listed here include various options to configure table storage space, segments, redundancy, streamloading, and indexes.
| Parameter | Type | Description |
|---|---|---|
index_name | string | An identifier for the index. The name must be distinct from the name of any existing index on the table. |
index_column | string | The name of the column for the index. Identical indexes on the same column are not allowed. A column can only have multiple indexes if they are of different types or parameters. |
index_type | string | Optional. One of these supported secondary index types: INVERTED | HASH | NGRAM | SPATIAL | ZONE_MAPIf unspecified, this value defaults to an index type based on its data type. For details, see Index Type Requirements and Defaults. |
retention_granularity | numeric | A number that represents the amount of time before the system deletes data in the table. You must pair this number with a specific time type, represented by the retention_value parameter.For details about setting up retention policies, see Table Retention Policies. |
retention_value | string | The unit of time that represents how long the table retains data. Supported values are: WEEK, DAY, HOUR, MINUTE, SECOND, MILLISECONDYou must pair this number with the amount of time, represented by the retention_granularity parameter.For example, 1 DAY schedules the table retention to a granularity of one day. |
storage_space_name | string | An identifier for the STORAGESPACE. |
segment_value | numeric | A value to define the size of the segment. |
segment_part | string | Specifies the segment part redundancy of the table. Supported values include: \{ DATA | MANIFEST | INDEX | SUMMARY_STATS | STATS }These settings are defined as follows: DATA: The actual data for the table.MANIFEST: Header information stored about the data, which describes how to locate any specified cluster of rows within the data.INDEX: The index of the data used for quicker lookups and better query performance.SUMMARY_STATS: A collection of statistics on the data that includes compression, row count, and average column size.STATS: Used in the optimizer, the probability density function and combinable distinct estimators used to make better optimizations to query plans. |
redundancy_scheme | string | The redundancy scheme. Supported values include: \{ COPY | PARITY }These settings are defined as follows: COPY: A copy of the bytes is stored throughout the storage cluster to ensure redundancy. This option uses more storage but is faster during rebuilds and node outages.PARITY: Using the parity encoding specified on the storage cluster, this option uses parity bits to ensure redundancy for the data. This option uses less storage but is slower during rebuilds and node outages. |
streamloader_json | string | A JSON string that defines the streamloader parameters. For details, see ALTER TABLE STREAMLOADER PROPERTIES. |
trades.
The table uses the TIMESTAMP column created_at as the TimeKey, with the granularity set at 1 hour. The columns ticker_symbol and t_type are defined as the table clustering keys. The example also includes a streamloader property pageQueryExclusionDuration to delay how soon data pages that were recently added can be included in query results.
SQL
CREATE TABLE AS SELECT (CTAS)
CTAS provides the ability to create and load a new table from the result of a query on one or more existing tables. The first column of the query result maps to the first column of the new table definition, the second column maps to the second column of the new table, and so on. The new table is available for querying after it has been created, and the entire result set from the query has been loaded into the table. When you receive a response to the CTAS SQL statement, the load is complete, and the table is ready. When you create a table from aSELECT SQL statement, the schema for the table can be automatically determined based on the query results. You can override this behavior with an alternative schema, provided the query results can automatically be cast to the target column types. CTAS also supports all syntax options for the new table. CTAS does not support default values and explicit nullable definitions on the column of the table.
CTAS statements support secondary and prefix indexes.
To create a table, you must have both the CREATE TABLE privilege for the current database and the SELECT privilege on all referenced tables and views.
For syntax and parameter information, see CREATE TABLE.
Default Table Definitions
By default, a new table created with a CTAS statement retains column names, data types, and nullable definitions from the queried table. You can override this configuration with alternate table definitions in the CTAS statement. Examples These CTAS examples select columns from theoriginal_table table that this CREATE TABLE statement defines. This table contains these columns:
col_int— Non-nullable integer with the default value123456789col_bigint— Non-nullable 8-byte signed integercol_id— Non-nullable integercol_point— Non-nullable point with the default valuePOINT(0 0)col_timestamp— Non-nullable TimeKey with granularity set at 1 daycol_varchar— Variable-length character string with a maximum length of 255 characters and Zstandard compression
ck using the col_bigint and col_id columns. It also has two secondary indexes: a hash index idx_01 on the col_varchar column and a spatial index on the idx_02 column.
SQL
original_table table.
SQL
basic_ctas table includes all the columns and data types from the original table definition. However, it does not include the segment keys, indexes, or the compression on the col_varchar column. The EXPORT TABLE SQL statement shows the differences in the basic_ctas table.
SQL
Text
REDUNDANCY, STORAGESPACE, and SEGMENTSIZE are all default table settings.
CTAS Using a Full Table Definition
This example CTAS statement includes a more detailed table definition. The definition includes new columns for the TimeKey, Clustering Key, and secondary indexes. The example also makes various changes from the original_table schema:
- Different column default value
- Different compression scheme (dynamic compression)
- New TimeKey granularity of 1 hour
- Three columns in the Clustering Key
- Different secondary index types (
NGRAMandSPATIAL)
SQL
col_int, col_bigint, and col_id, from the original table to insert into the new subset table. The example also specifies alternate table options for REDUNDANCY and SEGMENTSIZE.
SQL
Due to limitations of the JDBC API, the reported modified row count might not be accurate for tables larger than two billion rows.
col_int_multiplycolumn is the multiplication of thecol_intvalues by 10.col_month_addcolumn is the result of adding three months to eachcol_timestampcolumn value.col_yearcolumn is the extraction of the year value from eachcol_timestampcolumn value.col_substringcolumn contains the first three characters from eachcol_varcharcolumn value.
SQL
CTAS USING LOADERS
Specify one or more Loader Nodes for executing the CTAS SQL statement. If you do not use this option, the Ocient System uses all Loader Nodes that are live to execute the SQL statement. This statement is useful for managing loading operations, particularly when balancing multiple loads of different sizes and resource requirements. Alternatively, this statement can also help simplify small batch loads by sourcing the data from a single Loader Node. Syntax| Parameter | Type | Description |
|---|---|---|
streamloader | string | A unique name for the Loader Node. Identify the names of Loader Nodes from the sys.nodes table by using this query: SELECT name FROM sys.nodes;If the name of the Loader Node contains special characters, you must enclose it in quotes, such as "stream-loader1". |
query | string | A SELECT query that defines values or a table and any of its columns to use for data in the specified table_name table. |
For the query to execute successfully, the specified names of the Loader Nodes must:
- Identify nodes that are live.
- Identify nodes that have the Loader role.
my_schema.my_ctas_table_2 with a clustering index named idx on the int_col column with the values in the int_col column in the table named my_schema.my_table. Use the Loader Node named stream-loader1 to execute this SQL statement.
SQL
stream-loader2 and stream-loader3.
SQL
DROP TABLE
DROP TABLE removes one or more existing tables in the current database, along with all associated views.
This action cannot be undone.
DELETE TABLE privileges for the table.
Syntax
SQL
| Parameter | Type | Description |
|---|---|---|
table_name | string | A unique identifier for the table. You can drop multiple tables by specifying additional table names and separating each with commas. |
employees.
SQL
employees and departments.
SQL
IF EXISTS statement to convert the error to a warning. If you execute the DROP TABLE statement and only some of the tables exist while other tables are missing, the database drops the existing tables and returns warnings for each missing table.
ALTER TABLE
ALTER TABLE RENAME
ALTER TABLE RENAME renames an existing table.
Required Privileges
To rename a table, you must have the ALTER TABLE privilege for the table.
The Ocient System requires these privileges if this statement includes a change to the schema:
VIEWprivilege on the current schema of the tableVIEW TABLEandCREATE TABLEprivileges on the target schema (if the schema already exists)CREATE TABLEprivilege on the database (if the schema does not exist)
SQL
| Parameter | Type | Description |
|---|---|---|
old_table_name | string | The name of the table to alter. |
new_table_name | string | The new name to replace old_table_name. |
us.employees to mid_west_employees.
SQL
us.employees to north_america.employees.
SQL
ALTER TABLE RENAME COLUMN
ALTER TABLE RENAME COLUMN renames an existing column.
To rename a column, you must have the ALTER TABLE privilege for the table.
Syntax
SQL
| Parameter | Type | Description |
|---|---|---|
table_name | string | A unique identifier for the table. |
old_column_name | string | The name of the table column to alter. |
new_column_name | string | The new column name to replace old_column_name. |
name in the table employees in the current database and schema to first_name.
SQL
ALTER TABLE ADD COLUMN
ALTER TABLE ADD COLUMN adds a new column to the table.
To add a column, you must have the ALTER TABLE privilege for the table.
New columns must either be nullable or specify a default value.
For a defined list of column parameters, see Column Definition. For constraints, see Column Constraint.
Syntax
SQL
| Parameter | Type | Description |
|---|---|---|
table_name | string | A unique identifier for the table. |
employees table in the current database and schema with the default value of 0.
SQL
SQL
ALTER TABLE ALTER COLUMN COMPRESSION
ALTER TABLE ALTER COLUMN COMPRESSION alters an existing column in the table to change its compression scheme.
Supported compression schemes are COMPRESSION NONE, COMPRESSION DYNAMIC, and COMPRESSION ZSTD.
Altering the compression setting of a column only affects compression for data loaded after you execute the SQL statement.
SQL
| Parameter | Type | Description |
|---|---|---|
table_name | string | The name of the table containing the column to alter. |
column_name | string | The name of the column to alter. |
compression_scheme | string | Supported values for the compression schemes are: COMPRESSION NONE specifies no compression applied.COMPRESSION DYNAMIC applies only if the column data is dynamically determined to be compressible.COMPRESSION ZSTD applies to VARCHAR columns as well as other data types. For this option only, you can specify these additional parameters:compression_level — This value signifies how much compression the data receives. The default value is 0. The full range of values is from -7 through 15. The database uses less memory when this value is lower, whereas more memory when this value is larger. Larger values provide better compression.dictionary_size — Dictionary size specified as a positive integer that signifies the size of the shared compression dictionary in bytes. The default value is 32768 (32K). The full range of values is from 4096 (4K) through 1048576 (1MB). This value denotes the amount of memory consumed during segment generation. In general, larger values provide better compression but use more memory. |
employee_name in the table employees in the current database and schema.
SQL
employee_name in the table employees in the current database and schema.
SQL
ALTER TABLE ALTER REDUNDANCY
ALTER TABLE ALTER REDUNDANCY alters the segment part redundancy for future segments of an existing table.
Note that altering a segment part redundancy setting only affects data loaded after applying the SQL statement.
SQL
| Parameter | Type | Description |
|---|---|---|
table_name | string | The name of the table that you want to alter. |
segment_part | string | Specifies the segment part redundancy of the table. Supported values include: \{ DATA | MANIFEST | INDEX | PDF | CDE | STATS }These settings are defined as follows: DATA: The actual data for the table.MANIFEST: Header information stored about the data, which describes how to locate any given cluster of rows within the data.INDEX: The index of the data used for quicker lookups and better query performance.STATS: Used in the optimizer, the probability density function and combinable distinct estimators used to make better optimizations to query plans. |
redundancy_scheme | string | The redundancy scheme. Supported values include: \{ COPY | PARITY }These settings are defined as follows: COPY — The system stores a copy of the bytes throughout the storage cluster to ensure redundancy. This option uses more storage but is faster during rebuilds and node outages.PARITY — The system uses the parity encoding specified on the storage cluster, and uses parity bits to ensure redundancy for the data. This option uses less storage but is slower during rebuilds and node outages. |
STATS part to COPY redundancy.
SQL
ALTER TABLE DROP COLUMN
ALTER TABLE DROP COLUMN drops an existing column from the table.
You cannot remove the TimeKey column and the clustering key columns from the table.
When you remove a column, the database does not remove or free any actual data.
SQL
| Parameter | Type | Description |
|---|---|---|
table_name | string | The name of the table to alter. |
column_name | string | The name of the column to drop. |
address from the table employees.
SQL
ALTER TABLE STREAMLOADER_PROPERTIES [#alter-table-streamloader_properties]
ALTER TABLE STREAMLOADER_PROPERTIES resets the table streamloader properties to the provided string. The properties string must be in valid JSON format.
The database registers streamloader changes dynamically. Therefore, you do not need to restart nodes or take other actions for the changes to take effect.
Any properties not specified in the string default to the system-wide setting.
SQL
| Parameter | Type | Description |
|---|---|---|
table_name | string | The name of the table to alter. |
streamloader_json | string | The streamloader properties to alter. See this table for a list of all supported properties. |
Configuring Streamloader Properties
STREAMLOADER_PROPERTIES is a field on the table metadata that must be written as a JSON string in order to be read properly. The database can dynamically render any changes to STREAMLOADER_PROPERTIES with the ALTER TABLE SQL statement. You can set Loader Node properties for a new table as a parameter in the CREATE TABLE SQL statement. You do not need to restart the database node for the changes to take effect.
Per-Table Streamloader Properties
| Parameter | Data type | Description |
|---|---|---|
pageQueryExclusionDuration | An integer in nanoseconds (ns) or a string with the suffix ns, us, ms, or s appended. For example: "10s" = 10 seconds, "1000us" = 1,000 microseconds | Per-table configuration for the time interval for pages that should be excluded from queries. The database excludes pages with time column values that are greater than the duration of the query. A value of 0 means the database does not exclude any pages. By default, this value is set to 0 if not specified. |
employees to {"pageQueryExclusionDuration" : "30s"}. This means that any pages added less than 30 seconds ago will not be included in query results.
SQL
ALTER TABLE DISABLE INDEX
TheALTER TABLE DISABLE INDEX statement instructs future queries not to use the specified indexes, but existing segments and new segments continue to have the index available in case you enable the index again.
All secondary indexes except for secondary clustering key indexes can be disabled. Trying to disable other types of indexes generates an error.
You can specify the index by name or UUID.
Syntax
SQL
| Parameter | Type | Description |
|---|---|---|
table_name | string | The name of the table to alter. |
index_name_or_uuid | string | The name or UUID of the index to disable. If you specify the index by name, the name must match an existing index. If you specify a UUID instead, it does not have to match an existing index. Therefore, you can disable a dropped index using its UUID, which ensures it is not used within old segments that were loaded with the index. You can get a list of index names and UUIDs in your database by referencing the sys.indexes table in the system catalog. |
current_idx on the table employees.
SQL
5c15d8de-36fa-4055-9bdc-3f1750aaeea0.
SQL
current_idx and other_idx on the table employees.
SQL
ALTER TABLE ENABLE INDEX
TheALTER TABLE ENABLE INDEX statement reverts the operation performed by the ALTER TABLE DISABLE INDEX statement.
Syntax
SQL
| Parameter | Type | Description |
|---|---|---|
table_name | string | The name of the table to alter. |
index_name_or_uuid | string | The name or UUID of the index to enable. If you specify the index by name, the name must match an existing index. If you specify a UUID instead, it does not have to match an existing index. Therefore, you can disable a dropped index using its UUID, which ensures it is not used within old segments that were loaded with the index. You can get a list of index names and UUIDs in your database by referencing the sys.indexes table in the system catalog. |
current_idx on the table employees.
SQL
5c15d8de-36fa-4055-9bdc-3f1750aaeea0.
SQL
current_idx and other_idx on the table employees.
SQL
ALTER TABLE ENABLE RETENTION POLICY AGE
ThisALTER TABLE SQL statement enacts a new retention policy on the specified table. A table can have only one retention policy. For details about retention policies, see Table Retention Policies.
Required Privileges
You must have the ALTER and DELETE privileges for the specified table.
Syntax
SQL
| Parameter | Type | Description |
|---|---|---|
table_name | string | The name of the table to alter. |
retention_granularity | numeric | A number that represents the amount of time before the system deletes data in the table. You must pair this number with a specific time type, represented by the retention_value parameter.For details about setting up retention policies, see Table Retention Policies. |
retention_value | string | The unit of time that represents how long the table retains data. Supported values are: WEEK, DAY, HOUR, MINUTE, SECOND, MILLISECONDYou must pair this number with the amount of time, represented by the retention_granularity parameter.For example, 1 DAY schedules the table retention to a granularity of one day. |
my_table that deletes any rows older than 1 day.
SQL
ALTER TABLE DISABLE RETENTION POLICY
ThisALTER TABLE SQL statement disables a retention policy on the specified table. For details about retention policies, see Table Retention Policies.
Required Privileges
You must have the ALTER TABLE system privilege and the ALTER privilege for the specified table.
Syntax
SQL
| Parameter | Type | Description |
|---|---|---|
table_name | string | The name of the table to alter. |
my_table.
SQL
DELETE FROM TABLE
Removes rows from the specified table. You can use theWHERE clause to specify the rows to remove. If a DELETE SQL statement lacks the WHERE clause, then the database deletes all rows in the table.
To use this statement, you must have the DELETE privilege for the table.
For details and examples, see Remove Records from an Ocient System.
DELETE actions cannot be undone.If a DELETE operation fails during execution, the database rolls back the changes and returns to its original state.Due to limitations of the JDBC API, the reported modified row count might not be accurate for
DELETE operations that are larger than two billion rows.SQL
| Parameter | Type | Description |
|---|---|---|
table_name | string | The name of the table, specified as a string, indicates where to delete rows. |
cte | string | A common table expression that defines temporary data for the DELETE statement. For details about using common table expressions, see WITH. |
<filter_clause> | None | A logical combination of predicates that filter the rows to delete based on one or more columns. For details, see the WHERE clause. The DELETE SQL statement removes all rows from a table if you do not include the WHERE clause. |
DELETE SQL statement removes all rows in the movies table that have a budget of less than 10000.
SQL
WITH keyword to find rows representing all transactions that occurred before 2022 that are less than $100. The DELETE SQL statement receives the results from the common table expression. Then, the database executes this statement to delete the corresponding rows.
SQL
EXPORT TABLE
EXPORT TABLE shows the CREATE TABLE statement for an existing table in the current database.
To export a table, you must have the SELECT TABLE privilege for the table.
SQL
| Parameter | Type | Description |
|---|---|---|
table_name | string | The name of the table that you want to export. |
trades.
SQL
SQL
INSERT INTO TABLE
INSERT INTO inserts rows into a table in the current database using literal values, column references, function executions, computed expressions, or column default values.
This SQL statement requires the INSERT privilege for the relevant table.
Due to limitations of the JDBC API, the reported modified row count might not be accurate for insert operations that are larger than two billion rows.
SQL
Using
DEFAULT VALUES inserts a single row where each target column is populated with its column defaults (as defined in the column definition) instead of an explicit VALUES list.For table columns that do not each have a defined default value, the inserted row is NULL. If the column has no default and also has the NOT NULL constraint, the insert operation generates an error.| Parameter | Type | Description |
|---|---|---|
table_name | string | The name of the table for insertion. |
col1, col2 [, ... ] | string | A list of specific columns to insert specific values. This column list defaults to all columns in the table if you do not specify any column names. The INSERT statement can use a subset of the table columns. Any columns not included in the statement are populated with their column default value in their column definition. If the column definition does not specify a default, the inserted row is NULL. If the column has no default and also has the NOT NULL constraint, the insert operation generates an error. |
cte | string | A common table expression that defines temporary data for the INSERT statement. For details about using common table expressions, see WITH. |
query | string | A SELECT query that defines values or a table and any of its columns that should be inserted into the specified table_name. |
row1_exp1, row1_exp2 [, ...] | string | The expressions to insert into columns in the table. This list must match the number of columns specified in the INSERT statement. Similarly, each expression must match the data type of the column that corresponds to its position. Expressions can be any of the following: L****iterals: 1, 3.14, ‘abc’, DATE '2024-01-01', etc.Column references: If your INSERT statement includes a common table expression using a WITH clause, you can reference columns from the separate table in that clause.Function executions: ABS(-5), NOW(), ST_DISTANCE, etc.Computed expressions: price * quantity, COALESCE(x, 0), etc.Column default values: Use the keyword DEFAULT to insert a default value specified in the column definition. If the column definition does not specify a default, the inserted row is NULL. If the column has no default and also has the NOT NULL constraint, the insert operation generates an error. |
system.table_b into system.table_a.
SQL
system.table_b.id_col_b into system.table_a.id_col_a and system.table_b.int_col_b into system.table_a.int_col_a.
SQL
product— Product identifierquantity— Quantity of the product soldsale_date— Date of sale
SQL
SQL
sales table before inserting rows into the monthly_sales_summary table.
The example uses the monthly_sales_summary table created by this CREATE TABLE statement with these non-nullable columns:
product_id— Product identifiermonth— Month part of the datetotal_quantity— Total quantity of the product
SQL
WITH keyword extracts the month from the sale date sale_date and calculates the sum of the quantity sold total_quantity of the product from the sales table before inserting this data. Then, the INSERT SQL statement specifies to insert the data into the monthly_sales_summary table.
SQL
customers table with these columns:
customer_id— Customer identifiername— Customer namestatus— Customer status with the defaultactivestatuscreated_at— Created date
SQL
DEFAULT VALUES keyword to insert one row of default values into the table. For columns that lack a defined default value, the operation inserts a NULL row.
SQL
status column, which has the active default value.
SQL
SQL
DEFAULT keyword as one of the row values in the INSERT statement.
SQL
SQL
INSERT INTO TABLE USING LOADERS
Specify one or more Loader Nodes for executing theINSERT INTO SQL statement. If you do not use this option, the Ocient System uses all Loader Nodes that are live to execute the SQL statement.
This statement is useful for managing loading operations, particularly when balancing multiple loads of different sizes and resource requirements. Alternatively, this statement can also help simplify small batch loads by sourcing the data from a single Loader Node.
Syntax
SQL
| Parameter | Type | Description |
|---|---|---|
streamloader | string | A unique name for the Loader Node. Identify the names of Loader Nodes from the sys.nodes table by using this query: SELECT name FROM sys.nodes;If the name of the streamloader contains special characters, you must enclose it in quotes, such as "stream-loader1". |
For the query to execute successfully, the specified names must:
- Identify nodes that are live.
- Identify nodes that have the Loader role.
system.table_b.id_col_b into system.table_a.id_col_a and system.table_b.int_col_b into system.table_a.int_col_a. Use the Loader Node named stream-loader1 to execute this SQL statement.
SQL
stream-loader2 and stream-loader3.
SQL
TRUNCATE TABLE
TRUNCATE TABLE removes some or all records from an existing table in the current database. The system deletes the truncated data, but the table and its schema remain intact in the system even if all data is deleted. If the entire table is truncated, Global Dictionary Compression tables remain in place.
To truncate a table, you must have the DELETE privilege for the table.
To remove a subset of rows from a table, you can use the DELETE FROM TABLE SQL statement.
For details and examples of using TRUNCATE, see Remove Records from an Ocient System.
Syntax
SQL
| Parameter | Type | Description |
|---|---|---|
table_name | string | The name of the table to truncate. |
segment_group_id | numeric | Identifier of the segment group. |
students.
SQL
us.students.
SQL
students.
SQL
us.students.
SQL

