env.DB from as many functions as need it — or from the CLI and REST API without deploying anything at all.
There is no server to size and nothing to deploy per database. Every path reaches the same data through one primary, so writes serialize and there is no replica lag to reason about.
Two Ways to Reach a Database
The same database is reachable two ways. Pick based on where the code runs.
A row written by a function is visible to the next CLI query, and a table created from the CLI is visible to the next request. That is what lets schema exist before any code does: create the database, apply migrations, then ship a function that binds it.
SQL Databases vs Per-Actor SQL
Stateful Actors also have SQLite, atctx.storage.sql. Both surfaces are SQLite, which is where the confusion starts. They solve different problems.
A per-actor database cannot be queried from outside its actor and cannot join across instances; there is no CLI or REST path to it. A SQL database can be queried from anywhere, but no caller gets exclusive access to it — concurrent callers interleave, and correctness across statements comes from
batch(), not from holding the database. Explicit BEGIN is rejected on both surfaces; the runtime owns transaction boundaries.
Next Steps
- Quick Start — Create a database, apply a schema, bind it, query it
- How SQL Databases Work — The single primary, sharing, and what durability means today
- Migrations — Versioned schema changes with
storage sqldb migrations - Runtime API — The
envbinding surface (SqlDatabase) - CLI Commands — Create, inspect, and query databases from the terminal
- Limits — Size and duration ceilings, and known gaps
Related Resources
- Bindings — How the
envbinding surface works - Stateful Actor SQL — The private, per-instance SQLite database
- KV — Key-value storage for read-heavy lookups
- CLI reference — The full
telnyx-edgecommand surface