Skip to main content

SQL Reference

ScramDB is a PostgreSQL wire-compatible SQL database. Connect with psql, any PostgreSQL driver, or any BI tool that supports PostgreSQL.

Compatibility​

ScramDB implements the PostgreSQL wire protocol (v3) and supports standard SQL syntax. You can connect using:

psql -h localhost -p 5432 scramdb

Or any PostgreSQL driver:

  • Python: psycopg2, asyncpg, sqlalchemy
  • Rust: tokio-postgres, sqlx
  • Go: pgx, database/sql with lib/pq
  • Java: JDBC PostgreSQL driver
  • Node.js: pg, knex

What's Supported​

ScramDB supports a broad, PostgreSQL-compatible SQL surface across transactional and analytical workloads, on one live copy of your data:

CategoryDetails
SELECT with joinsInner, left, right, full outer, cross, and LATERAL joins, plus subqueries and IN / EXISTS
CTEsWITH, recursive WITH RECURSIVE, and writable CTEs (INSERT / UPDATE / DELETE inside WITH)
Aggregate functionsSUM, COUNT, AVG, MIN, MAX, STDDEV, VARIANCE, STRING_AGG, and more, with FILTER
Window functionsROW_NUMBER, RANK, DENSE_RANK, LAG, LEAD, NTILE, aggregate windows, and frame clauses
80+ scalar functionsString, math, date/time, JSONB, and array functions - see Functions
ExpressionsCASE, BETWEEN, LIKE/ILIKE, COALESCE, NULLIF, IN, EXISTS
Set operationsUNION, INTERSECT, EXCEPT (and their ALL variants)
GROUPING SETSGROUPING SETS, ROLLUP, CUBE
DMLINSERT, UPDATE, DELETE, TRUNCATE, COPY, INSERT ... ON CONFLICT, MERGE, UPDATE ... FROM, DELETE ... USING, RETURNING
DDLCREATE / DROP / ALTER TABLE, indexes (including partial and expression indexes), views, materialized views, schemas, sequences, and table partitioning
Prepared statementsPREPARE / EXECUTE
CursorsDECLARE / FETCH / CLOSE
Stored procedures and functionsCREATE FUNCTION / CREATE PROCEDURE in PL/pgSQL
TriggersRow, statement, INSTEAD OF, and event triggers
TransactionsRead Committed, Repeatable Read, and Serializable isolation, with SAVEPOINT / ROLLBACK TO
Row lockingSELECT ... FOR UPDATE / FOR SHARE, including SKIP LOCKED
Data typesUUID, JSONB, ARRAY, ENUM, DOMAIN, TIMESTAMPTZ, TIME, NUMERIC, and more - see Data Types
SecurityRole-based access control (RBAC), row-level security, and schemas with search_path
Vector similarityBuilt-in embeddings functions (cosine, dot) over JSON-array vectors
User-defined functionsWrite UDFs in JavaScript, TypeScript, Rust, Go, C, C++, Python, and Ruby, plus 15 built-in analytics packages
Recovery and branchingPoint-in-time recovery (CREATE DATABASE ... FROM src AT TIMESTAMP ...) and instant database branching (CREATE DATABASE ... CLONE ...)
GPU accelerationQuery acceleration on NVIDIA, AMD, and Apple Metal
Distributed clusterSerializable transactions across a multi-node cluster

πŸ“Š Data Types

PostgreSQL type compatibility table

πŸ“ Statements

DDL and DML statement reference

βš™οΈ Functions

80+ scalar, aggregate, and window functions