Developer beta 0.1.0-beta.1 documentation. The build is not available for download yet; these pages describe the beta as built and tested on Linux x86-64.
Schema
Tables
CREATE TABLE orders (
id BIGINT PRIMARY KEY,
user_id BIGINT NOT NULL,
total DOUBLE PRECISION DEFAULT 0,
note TEXT,
placed TIMESTAMP
);
- Column names are case-insensitive unless quoted (
"MixedCase"). - A table has one primary key: one or more columns, or a hidden row id when none is declared. Integer keys are stored in key order; text and composite keys are hashed, and the key columns are stored with the row and checked on every read, so a hash collision is detected rather than returning the wrong row.
DEFAULTaccepts a literal; a column added later with a default reads the default for existing rows.- Table and column identities are stable: renaming keeps the data; dropping a column hides it and a new column with the same name is a new column.
Indexes
CREATE INDEX orders_user ON orders (user_id);
CREATE UNIQUE INDEX orders_note ON orders (note);
DROP INDEX orders_user;
Secondary indexes make equality lookups (WHERE user_id = $1) fast and
enforce uniqueness. They are rebuilt from the table at open, so they can
never be stale or corrupt after a crash. A column that has an index cannot
be dropped until the index is dropped.
Changing tables
ALTER TABLE orders ADD COLUMN currency TEXT DEFAULT 'EUR';
ALTER TABLE orders RENAME COLUMN note TO comment;
ALTER TABLE orders DROP COLUMN comment;
ALTER TABLE orders RENAME TO purchases;
Schema changes are their own transactions (they cannot run inside
BEGIN … COMMIT), take effect atomically, and invalidate open cursors.
Adding a primary key column or changing a column’s type is not supported;
create a new table and copy the data.
Introspection
SHOW TABLES; -- table_name, columns, primary_key, indexes, rows, engine_table
SHOW COLUMNS FROM orders; -- column_name, type, nullable, default, primary_key, field_id
DESCRIBE orders; -- the same
SHOW INDEXES FROM orders; -- index_name (PRIMARY KEY first), columns, unique
The same information is in holadb inspect <target> [table], in the
Studio’s table browser, and, for PostgreSQL clients, through these
statements (the pg_catalog tables are not emulated, so psql’s \d is
not available; use SHOW COLUMNS FROM t).
Limits
| Limit | Value |
|---|---|
| rows returned by one statement | 1,048,576 (use a cursor for more) |
| open cursors per connection | 64 |
| statement text | 1 MiB |
| parameters per statement | 65,535 |
rows in one INSERT … VALUES |
100,000 |