Files
rdbms-playground/website/src/content/docs/reference/tables.md
T
claude@clouddev1 936d9254c0 feat: add "Using the playground" section + Reference skeleton
Restructure the docs into five top-level sections, splitting the
application you drive from the database language you build with.

- New "Using the playground" section: command-line options; the assistive
  editor (completion, highlighting, [ERR]/[WRN] indicator, hints, in-line
  editing); the output pane (scrolling); projects (save/load/new/rebuild);
  undo/redo & history; export & import; clipboard; getting help. Grounded in
  the in-app help/usage and ADR-0003/0022/0027.
- Reference: seed the remaining topic pages (Columns, Relationships,
  Indexes, Constraints, Inserting & editing data, Querying & inspecting)
  with real syntax synopses; worked examples to follow.
- Surface the assistive editor on the landing page and in Getting started;
  restore cross-links now that targets exist.

Plan + STYLE updated to the five-section structure. 24 pages, build green,
links resolve, content clean; planned features carry "planned" callouts.
2026-06-10 10:40:07 +00:00

2.1 KiB

title, description, sidebar
title description sidebar
Tables Create and drop tables in simple mode and in advanced-mode SQL, including compound primary keys.
order
2

A table is the core building block. This page covers creating and removing tables; changing a table's columns after it exists is covered in Columns.

Create a table (simple mode)

The simplest way to create a table is with pk on its own — it gives the table a ready-made primary-key column named id that the database fills in for you:

create table authors with pk

Prefer to name the key, or give it a specific type? Name it in the with pk clause:

create table authors with pk author_id(serial)

Either way, the rest of the columns are added afterwards with add column:

add column to authors: name (text)
add column to authors: birth_year (int)

Compound primary keys

To make the primary key span more than one column, list them, comma separated:

create table loans with pk book_id(int), member_id(int)

Syntax

create table <Name> with pk [<col>(<type>)[, ...]]

Create a table (advanced mode)

In advanced mode you write a full CREATE TABLE with every column and constraint inline:

create table authors (
  author_id serial primary key,
  name text not null,
  birth_year int
)

The advanced form also accepts table-level constraints and inline foreign keys — see Constraints and Relationships.

Syntax

create table [if not exists] <Name> (<col> <type> [constraints], ...)

Drop a table

drop table authors

In advanced mode you may add if exists so removing a table that is not there succeeds quietly:

drop table if exists authors

:::caution Dropping a table removes its rows as well. Use undo if you drop one by mistake. :::

Renaming a table

Renaming a table is available in advanced mode:

alter table authors rename to writers

There is no simple-mode rename verb — switch to advanced mode (or use the one-line : escape) to rename a table.