> codebench_TOOL: HomeLOCAL-ONLY⌘K Switch

DDL Compare

Tool guide

Compare DDL schemas and generate migration SQL

Input: This tool processes input in your browser. Check in Network (opens in a new tab)

Dialect:
Current Schema (DDL)
Target Schema (DDL)

Parse and compare DDL schemas to generate migration SQL automatically. Detects added, dropped, and modified tables, columns, indexes, views, and sequences. Generates dialect-specific ALTER TABLE, CREATE, and DROP statements. Supports 8 SQL dialects. All processing runs in your browser — zero data upload.

How to use it

  1. Select SQLite. Paste the original table into Current Schema (DDL) and the revised table into Target Schema (DDL).
  2. Keep Generate DROP checked and choose Compare DDL. Find these two statements among the generated comments.
  3. Turn off Generate DROP and compare again. The ADD remains and the DROP disappears. Neither comparison copies the old shelf values into the new column.

Worked example

Current Schema (DDL)
CREATE TABLE score_copies (
  copy_id INTEGER PRIMARY KEY,
  shelf_code TEXT
);
Target Schema (DDL)
CREATE TABLE score_copies (
  copy_id INTEGER PRIMARY KEY,
  location_code TEXT
);
Example output
ALTER TABLE "score_copies" ADD COLUMN "location_code" TEXT;
ALTER TABLE "score_copies" DROP COLUMN "shelf_code";

The diff sees an added name and a removed name. It does not infer that these names refer to the same data. ADD creates a new empty column here; DROP would remove the old values.

What to watch for

Do not run the generated SQL as a rename. Review Logs for unparsed statements, and rehearse the intended migration on a disposable database with known rows first.

Frequently asked question

Does turning off Generate DROP preserve the old values under the new name?
No. In this example it only suppresses the removal. The old value stays under shelf_code, and location_code reads NULL on those existing rows until you change the migration or populate the column.

Browse SQL tools

Further reading

> codebench $Ctrl+Enter Run