Lakebase Postgres is standard Postgres, so you create tables with standard CREATE TABLE syntax. Run the statement from the Neon SQL Editor in the Console, from psql, or through any application driver, and pick column types and constraints the same way you would on any Postgres server. For anything beyond a quick experiment, use a migration tool so your schema lives in version control.
Create a table
This example uses common Postgres types and constraints:
CREATE TABLE users (
id BIGSERIAL PRIMARY KEY,
email TEXT NOT NULL UNIQUE,
display_name TEXT,
is_active BOOLEAN NOT NULL DEFAULT TRUE,
metadata JSONB NOT NULL DEFAULT '{}'::jsonb,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE TABLE posts (
id BIGSERIAL PRIMARY KEY,
user_id BIGINT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
title TEXT NOT NULL,
body TEXT,
published BOOLEAN NOT NULL DEFAULT FALSE,
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE INDEX posts_user_id_idx ON posts (user_id);Why these choices:
BIGSERIALgives you an auto-incrementing 64-bit primary key.BIGINT GENERATED ALWAYS AS IDENTITYis the SQL-standard alternative and the better default for new schemas.- Use
TEXTinstead ofVARCHAR(n)unless you need a length limit. Postgres stores both the same way. TIMESTAMPTZ(timestamp with time zone) is almost always the right time type.JSONBlets you store and index JSON. Use it for flexible attributes, and use regular columns for anything you query often.REFERENCESadds a foreign key. Postgres doesn't index the referencing column for you, so add an index on it yourself, as the example does forposts.user_id.
Where to run it
- Open the Neon Console and select your project.
- Select Postgres database > SQL Editor.
- Select a branch and database.
- Paste the
CREATE TABLEstatement and click Run.
The SQL Editor also supports meta-commands like \dt (list tables) and \d users (describe a table). See Meta-commands.
Use a migration tool for real schemas
Ad-hoc CREATE TABLE is fine for prototyping. Once a schema needs to change over time, use a migration tool such as Drizzle, Prisma Migrate, Alembic, dbmate, Flyway, or sqlx. Migrations keep your schema in version control and apply the same changes in every environment. They also fit Neon's branching workflow: you can run a migration on a branch before you run it on production.

Step-by-step guides for Drizzle, Prisma, SQLAlchemy, and more.








