SQLite DDL and Schema Design Cheatsheet/Rebuild a table for complex changes

Canonical pattern for dropping constraints or changing types.

Section: Change schemas safely

Rebuild a table for complex changes

sql
sql
BEGIN;
CREATE TABLE users_new (
  id INTEGER PRIMARY KEY,
  email TEXT NOT NULL UNIQUE,
  full_name TEXT,
  timezone TEXT
);
INSERT INTO users_new (id, email, full_name, timezone)
SELECT id, email, display_name, timezone FROM users;
DROP TABLE users;
ALTER TABLE users_new RENAME TO users;
COMMIT;
Explanation

SQLite supports many schema changes, but rebuilds are still the practical pattern for more invasive migrations.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Change schemas safely
Add a column
Append a new nullable or defaulted column.
OpenIn sheetsqlsame section
Rename a table
Change the table name without recreating data.
OpenIn sheetsqlsame section
Rename a column
Adjust a column name in-place.
OpenIn sheetsqlsame section
Create a basic table
Define a rowid-backed table with primary key and timestamps.
OpenIn sheetsql1 tag match
Use a CHECK constraint
Validate allowed values at the database layer.
OpenIn sheetsql1 tag match
Add a foreign key
Reference a parent table from a child table.
OpenIn sheetsql1 tag match