Skip to content

DDL — Data Definition

CREATE TABLE

CREATE TABLE table_name (
column1 TYPE,
column2 TYPE,
...
);

Supported Types

TypeDescriptionExample
TEXTUTF-8 string'hello'
INTEGER64-bit signed integer42
REAL64-bit floating point3.14
BOOLBooleanTRUE, FALSE
BLOBBinary dataX'DEADBEEF'

Examples

-- Basic table
CREATE TABLE users (
id TEXT,
name TEXT,
email TEXT,
age INTEGER
);
-- Create only if it doesn't exist
CREATE TABLE IF NOT EXISTS events (
id TEXT,
type TEXT,
payload TEXT,
timestamp INTEGER
);

DROP TABLE

DROP TABLE table_name;
DROP TABLE IF EXISTS table_name;

Dropping a table removes its metadata from __meta/table/<name>. Row data becomes orphaned but doesn’t affect the ledger’s integrity.

ALTER TABLE

ADD COLUMN

ALTER TABLE users ADD COLUMN phone TEXT;

Adds a new column to the table schema. Existing rows return NULL for the new column.

DROP COLUMN

ALTER TABLE users DROP COLUMN phone;

Removes a column from the table schema. This is a metadata-only operation — existing rows are not rewritten. The dropped column is excluded from all future projections. Primary key columns cannot be dropped.

RENAME COLUMN

ALTER TABLE users RENAME COLUMN email TO email_address;

Renames a column in the table schema. A column_aliases mapping is maintained so that existing rows stored with the old column name are automatically mapped to the new name on read.