npx wrangler d1 execute my-db --file ./schema.sql

Category: Cloudflare

npx wrangler d1 execute my-db --file ./schema.sql

Run a SQL file against D1

Executes every statement in schema.sql, the usual way to create tables and indexes or apply ad-hoc changes. Multiple statements run in one call, which is handy for seeding. For tracked, versioned schema changes, prefer migrations: `npx wrangler d1 migrations apply my-db`.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.