Materialize Logo

CREATE TABLE

Available only in unstable builds.

CREATE TABLE creates a non-streaming, in-memory data source.

WARNING! At the moment, tables do not persist any data that is inserted. This means that restarting a Materialize instance will lose any data that was previously stored in a table.

Conceptual framework

Tables store non-streaming data that is inserted via INSERT statements.

When to create a table

You might want to create a table when…

Syntax

CREATE TABLE table_name ( col_name col_type NOT NULL , )
Field Use
table_name A name for the table.
col_name The name of the column to be created in the table.
col_type The data type of the column indicated by col_name.
NOT NULL Do not allow the column to contain NULL values. Columns without this constraint can contain NULL values.

Details

Restrictions

Tables do not persist any data that is inserted. This means that restarting a Materialize instance will lose any data that was previously stored in a table.

Additionally, tables do not currently support: - Primary keys - Unique constraints - Check constraints - Default column values - Insert statements that use anything other than a VALUES clause, such as INSERT INTO ... SELECT - UPDATE ... and DELETE statements

Examples

Creating a table

We can create a table t with the following statement:

CREATE TABLE t (a int, b text NOT NULL);

Once a table is created, we can inspect the table with various SHOW commands.

SHOW TABLES;
TABLES
------
t

SHOW COLUMNS IN t;
Field      Nullable  Type
-------------------------
a          YES       int4
b          NO        text