Skip to main content
Creates a new table in the current database.

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 NULL insert – a direct insertion of a NULL value into a particular column.
  • An Implicit NULL insert – an INSERT statement with missing values for a particular column.
The following example creates a fact table t1 with five columns, specifying if each column can contain NULL values, their default values, and a primary index on col2:
After creating a table, you can manipulate the values using different 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:
STRUCT fields and columns:
ARRAY columns:

PRIMARY INDEX

The PRIMARY 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

The following table describes the primary index parameters:

PARTITION BY

The PARTITION 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.
The following subset of SQL functions can be used in PARTITION BY expressions: For more information, see Working with partitions.

Table type

Firebolt supports two types of tables:
  • FACT table - the data is distributed across all nodes of the engine.
  • DIMENSION table - the entire table is replicated in every node of the engine.
The CREATE TABLE command defaults to a 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 optional WITH (...) 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.
Firebolt also supports the following related functions: