Materialize Logo

CREATE TABLE

New in v0.5.0.

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 col_option , )

col_option

NOT NULL DEFAULT expr
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.
default_expr A default value to use for the column in an INSERT statement if an explicit value is not provided. If not specified, NULL is assumed.

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:

Examples

Creating a table

You can create a table t with the following statement:

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

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

SHOW TABLES;
TABLES
------
t

SHOW COLUMNS IN t;
name       nullable  type
-------------------------
a          true      int4
b          false     text
Did this info help?
Yes No