Syntax
Parameters
All identifiers are case-insensitive unless enclosed in double-quotes. For more information, see Object identifiers.
Column constraints and the default expression
Firebolt supports the following column constraints:Only literals and the following functions are supported in default expressions: CURRENT_DATE, LOCALTIMESTAMP, CURRENT_TIMESTAMP, and NOW, which is an alias for CURRENT_TIMESTAMP.
STRUCT fields within ARRAY columns cannot have UNIQUE constraints
Example: Creating a table with NULL and NOT NULL values
The following example illustrates different use cases for column definitions and INSERT statements:
- An Explicit
NULLinsert – a direct insertion of aNULLvalue into a particular column. - An Implicit
NULLinsert – anINSERTstatement with missing values for a particular column.
t1 with five columns, specifying if each column can contain NULL values, their default values, and a primary index on col2:
INSERT statements, as shown in the following examples:
Example creating table with UNIQUE constraint over columns
The following examples illustrates UNIQUE constraint over different column definitions : Primitive types:PRIMARY INDEX
ThePRIMARY INDEX is an optional sparse index that sorts and organizes data based on the indexed field as it is ingested, without affecting data scan performance. For more information, see Primary index.
Syntax
PARTITION BY
ThePARTITION BY clause defines one or more columns that determine how the table is divided into physical parts. These columns serve as the partition key and cannot allow NULL values. When multiple columns are used as the partition key, the combination of all of these columns define the partition boundaries.
PARTITION BY expressions:
- TO_YYYYMM
- TO_YYYYMMDD
- EXTRACT
(year|month|day|hour from <column_name>) - DATE_TRUNC
Table type
Firebolt supports two types of tables:FACTtable - the data is distributed across all nodes of the engine.DIMENSIONtable - the entire table is replicated in every node of the engine.
FACT table. DIMENSION tables are ideal for relatively small tables, up to tens of gigabytes, that are used in joins with FACT tables.
Storage Parameters
Storage parameters are specified in the optionalWITH (...) clause as comma separated <storage_parameter> = <storage_parameter_value> assignments.
All identifiers are case-insensitive unless enclosed in double-quotes. For more information, see Object identifiers.
DESCRIPTION
It is possible to add a description to the table as well as to the columns during the table creation.Related functions
Firebolt also supports the following related functions:- CREATE TABLE AS SELECT (CTAS) – - Creates a table and loads data into it based on a
SELECTquery. - CREATE TABLE CLONE – Creates a table that is a copy of an existing table in the database.