D1 Serverless SQLite Database
Serverless SQLManage Cloudflare D1 serverless SQLite databases, execute raw SQL queries, and apply schema migrations.
📖 Full Explanation
Cloudflare D1 is a serverless, relational database built on SQLite distributed across Cloudflare's global network. \1 provides an interactive terminal query engine to inspect tables, debug schema changes, and run instant SQL commands.
⚙️ Command Options & Flags
| Option / Flag | Description | Default |
|---|---|---|
| -q, --query <sql> | SQL statement to execute against the database | - |
| -f, --file <sql-file> | Execute SQL script file (for migrations) | - |
| --json | Return query results in JSON format | false |
🔬 Technical Corollary & Edge Mechanics
Executes queries via \1. Supports transactions, automatic read replication to edge locations nearest users, and consistent writes routed to the primary region.
🎯 Real-World DevOps Use Cases
Interactive Database Debugging
Quickly inspect user rows or system settings without opening an external SQL GUI.
Applying Edge Schema Migrations
Run migration scripts directly from CI/CD pipelines before deploying new Workers code.
💻 Live Output Simulation
$ cflare d1 query prod-db -q "SELECT id, status, count(*) FROM orders GROUP BY status;" ┌────┬───────────┬──────────┐ │ id │ status │ count(*) │ ├────┼───────────┼──────────┤ │ 1 │ completed │ 1,429 │ │ 2 │ pending │ 38 │ │ 3 │ refunded │ 12 │ └────┴───────────┴──────────┘ ✔ Executed in 14ms (Rows read: 1479, Rows written: 0)