SQL Schema Diff
Processed Client SideCompare two database table schemas, see every column that was added, removed, or changed, and generate the ALTER statements to sync either side.
Bookmark this tool now — skip the search next time you need it.
About SQL Schema Diff
This tool runs entirely in your browser. Whatever you paste is processed on your own device and is never uploaded, logged, or sent to any server.
The SQL Schema Diff compares two CREATE TABLE definitions and tells you exactly how they differ — which columns exist on only one side, which changed type, nullability, or default, and which constraints and indexes are missing from either. It then writes the ALTER statements that bring one schema in line with the other, in the dialect you choose. It is for the moment when staging and production have quietly drifted apart, or when a migration file needs writing and reading two CREATE TABLE statements side by side is not a reliable way to spot a changed VARCHAR length.
Key features
- Column-level diff reporting additions, removals, and changes to type, nullability, default, and primary key
- Constraint and index diffing, covering PRIMARY KEY, FOREIGN KEY, UNIQUE, CHECK, and plain indexes
- Generated ALTER statements for MySQL, PostgreSQL, SQLite, Oracle, SQL Server, or a generic dialect
- Correct per-dialect syntax: MySQL MODIFY COLUMN, PostgreSQL ALTER COLUMN … TYPE with separate SET NOT NULL and DEFAULT statements, Oracle MODIFY, and SQL Server ALTER COLUMN
- Identifier quoting per dialect — backticks for MySQL, double quotes for PostgreSQL and SQLite, brackets where appropriate
- A direction switch, so you can generate the migration to make either side match the other
- SQLite’s ALTER limitations flagged explicitly, with a note that the table needs rebuilding rather than a statement that will not run
- Tolerant parsing: quoted identifiers, comments, precision and length modifiers, UNSIGNED, AUTO_INCREMENT, and DEFAULT expressions
- Summary badges counting what is only in A, only in B, and changed — with everything computed in your browser
How to use it
- Paste the first CREATE TABLE statement into Schema A.
- Paste the one you are comparing it against into Schema B.
- Read the diff sections: only in A, only in B, changed columns, and constraint differences.
- Choose the direction — make B match A, or A match B — and select your database dialect.
- Review the generated ALTER statements and copy them into a migration file.
Tips & common mistakes
- Treat the generated SQL as a first draft, not a migration you run unread. It is accurate about the shape of the change and cannot know your data, your locking constraints, or your deployment order.
- A DROP COLUMN is not reversible and takes the data with it. Check every drop against what is actually in the table before running it anywhere that matters.
- Narrowing a column — VARCHAR(255) down to VARCHAR(64), or INT to SMALLINT — fails or truncates when existing rows do not fit. Query for oversized values first.
- Adding a NOT NULL column to a populated table needs a default, or it fails outright. The safe sequence is add nullable, backfill, then add the constraint.
- SQLite genuinely cannot alter a column’s type or constraints. The rebuild note is the real answer there: create a new table, copy the rows across, drop the old one, and rename.
- On a large MySQL or PostgreSQL table, an ALTER can lock or rewrite the whole thing. Check what your version does for the specific change before running it in production.
- Diff the schema you actually deployed, not the one in your migrations folder. The point of this tool is finding the drift between what you think is there and what is.
- For plain text or code rather than SQL schemas, use the general-purpose Compare Files / Diff Checker.