Creating Tables

A type defines the shape of your data. A table is where the actual rows live. Every table in TempestDB is backed by a type - every row stored in it must conform to that type's structure.

Creating a table also requires declaring a primary key: the field that uniquely identifies each row. Using the main.User type from the previous page:

create table main.users : main.User { primary key (id) };

The : main.User part tells TempestDB which type each row must match. The { primary key (id) } constraint ensures every row has a unique id.

Run .tables main to confirm the table was created.