SQL Boy
TutorialsPlayground

Format & Validate

SQL FormatterSQL MinifierSyntax Validator

Convert

JSON to SQLCSV to SQLSQL to JSONRegex to SQLExcel to SQLSQL Dialect Convertersoon

Visualize

ER Diagram GeneratorSQL Schema Diff

Generate

SQL Mock Data Generator

Analyze

SQL Query ExplainerSQL Query Analyzer

Workflow hubs

FormattingConversionSchemaAnalysis
View all tools
Daily ChallengeInterviewsCheat SheetBlog

© 2026 SQL Boy. Built for developers.

ContactPrivacyTermsAI Usage PolicyEditorial StandardsAboutRSS Feed

New conversation

What can I help with?

Ask about this page, get a hint on a challenge, or explore SQL concepts.

I know what's on this page and can give answers grounded in SQL Boy content.

Current page

Schema Diff

/tools/schema-diff

Usage status will load after login
SQL Boy
TutorialsPlayground

Format & Validate

SQL FormatterSQL MinifierSyntax Validator

Convert

JSON to SQLCSV to SQLSQL to JSONRegex to SQLExcel to SQLSQL Dialect Convertersoon

Visualize

ER Diagram GeneratorSQL Schema Diff

Generate

SQL Mock Data Generator

Analyze

SQL Query ExplainerSQL Query Analyzer

Workflow hubs

FormattingConversionSchemaAnalysis
View all tools
Daily ChallengeInterviewsCheat SheetBlog

SQL Schema Diff

Paste your old and new CREATE TABLE schemas. Instantly see every column and index change, and get a ready-to-run ALTER TABLE migration script.

Added columnsDropped columnsType changesIndex changesNew tablesDropped tables

Old Schema (before)

The current / existing schema

New Schema (after)

The target / updated schema

1 difference found1 modified

Changes by Table

ADD
phone

VARCHAR(20)

ADD
avatar_url

VARCHAR(500)

ADD
updated_at

DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP

ADDINDEX idx_username (username)

Migration Script

Migration Script
-- Migration script (generated by SQL Boy Schema Diff)
-- Review carefully before executing in production.

-- Modified table: users
ALTER TABLE `users`
  ADD COLUMN `phone` VARCHAR(20),
  ADD COLUMN `avatar_url` VARCHAR(500),
  ADD COLUMN `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  ADD INDEX `idx_username` (`username`);

How It Works

Three deterministic steps — no AI, no server, no guesswork.

01

Parse

Each schema is split into CREATE TABLE blocks. Each block is parsed into a list of columns (name + full type string) and constraints (PRIMARY KEY, UNIQUE KEY, INDEX, FULLTEXT). No external SQL engine is used — parsing runs entirely in the browser.

CREATE TABLE users (
  id   INT NOT NULL AUTO_INCREMENT,
  name VARCHAR(100) NOT NULL,
  PRIMARY KEY (id)
);

→ Table:   "users"
  Columns: id · name
  Indexes: PRIMARY KEY (id)

02

Diff

Tables are matched by name (case-insensitive). Within each matched table, columns are paired by name — new columns → ADD, missing columns → DROP, same name but different type string → MODIFY. Indexes are compared as a compound key of type + name + columns.

-- Same name, different type string → MODIFY
Old: name VARCHAR(100) NOT NULL
New: name VARCHAR(200) NOT NULL

-- In NEW only → ADD
New: email VARCHAR(255)

-- In OLD only → DROP
Old: legacy_flag TINYINT

03

Generate

Each detected change is emitted as an ALTER TABLE clause. New tables become a full CREATE TABLE statement; dropped tables become DROP TABLE IF EXISTS. All clauses are joined into one copy-pasteable migration script with inline comments.

ALTER TABLE `users`
  MODIFY COLUMN `name` VARCHAR(200) NOT NULL,
  ADD COLUMN `email` VARCHAR(255),
  DROP COLUMN `legacy_flag`;

Common Changes at a Glance

Every change type the tool can detect and the SQL it generates.

ChangeTrigger & Generated SQL
ADD

Add column

Column present in NEW schema only

ALTER TABLE `t` ADD COLUMN `col` VARCHAR(255);
DROP

Drop column

Column present in OLD schema only

ALTER TABLE `t` DROP COLUMN `col`;
MODIFY

Modify column

Same column name, different type/NULL/DEFAULT

ALTER TABLE `t` MODIFY COLUMN `col` BIGINT NOT NULL;
ADD

Add index

Index key in NEW schema only

ALTER TABLE `t` ADD INDEX `idx_col` (`col`);
DROP

Drop index

Index key in OLD schema only

ALTER TABLE `t` DROP INDEX `idx_col`;
ADD

New table

Table present in NEW schema only

CREATE TABLE `new_table` ( ... );
DROP

Drop table

Table present in OLD schema only

DROP TABLE IF EXISTS `old_table`;

Before You Run in Production

Schema migrations are irreversible. Keep this checklist handy.

Back up first

Take a full snapshot or logical dump before running any DDL in production. Schema migrations cannot be rolled back with a simple ROLLBACK.

Test on staging with real data volume

Run the migration on a staging copy that matches production row counts. A migration that takes 1 s on a dev database may lock a 50 M-row table for minutes.

Adding a nullable column is usually fast

MySQL 8+ and PostgreSQL 11+ can add a nullable column without a default as a metadata-only operation — no table rebuild necessary.

MODIFY COLUMN may rebuild the whole table

Changing a column's data type, length, or NULL constraint triggers a full table copy in MySQL. Use pt-online-schema-change or gh-ost for large tables to avoid downtime.

DROP COLUMN is permanent

Once executed you cannot undo a column drop. Confirm that no application code, ORM model, or report still references the column before running the script.

Use Schema Diff as part of a migration workflow

The diff output is most useful when it sits between design review and execution. Treat it as a fast structural checkpoint, not as permission to run DDL blindly.

Review a pull request schema change

Use this path when you have two CREATE TABLE versions and want a fast, explicit summary before approving a migration.

  1. 1Paste the current schema into Old Schema and the proposed schema into New Schema.
  2. 2Review per-table column and index changes before you read the generated SQL.
  3. 3Copy the migration script into version control, then adapt syntax for your target dialect if needed.

Prepare a safer production rollout

Useful when a schema change is real but you still need to decide whether it is operationally safe.

  1. 1Run the diff to surface rebuild-heavy operations like MODIFY COLUMN or DROP COLUMN.
  2. 2Check the production checklist and mark which statements need an online-schema strategy.
  3. 3Test the final migration on staging with realistic row counts before scheduling production.

Choose the right guide for the kind of schema change you saw

A diff can mean many things: a model redesign, a relationship or constraint change, or a boundary shift around JSON and sensitive fields. These paths help route the review correctly.

The diff is really telling you the model changed

Use this route when a migration review is exposing deeper schema-design questions rather than a simple column add or drop.

Designing Your First Database SchemaDatabase Normalization Explained

Indexes, keys, and relationships are the risky part

Relevant when the migration is changing foreign keys, uniqueness, or access patterns that may affect both correctness and performance.

Mastering SQL ConstraintsUnderstanding Database Indexes

Semi-structured fields or data boundaries are shifting

Choose this route when schema evolution is moving JSON fields, sensitive columns, or integration payloads into a new structure.

Working with JSON in SQLData Masking and Anonymization

Learn the concepts behind the diff

If the tool shows a change you are not comfortable shipping, use these guides to understand the data-model and index implications before you write a migration plan.

Designing Your First Database Schema

Good foundation if you are still deciding what the target table structure should look like.

Database Normalization Explained

Helpful when a diff is really signaling duplicated facts or a table that should be split before migrating it.

Working with JSON in SQL

Useful when the migration changes JSON columns or when semi-structured fields should become more explicit over time.

Mastering SQL Constraints

Helpful when the diff includes PRIMARY KEY, UNIQUE, or other integrity changes.

Understanding Database Indexes

Best follow-up when the schema diff shows index adds, drops, or rewrites.

Frequently Asked Questions

Review before running in production

Generated ALTER TABLE statements are a starting point. Always review the migration in a staging environment first, especially for large tables where adding/modifying columns requires careful planning around locking and downtime.

Related tools

Schema Design WorkflowSQL Query AnalyzerSQL Query ExplainerER Diagram GeneratorSQL Formatter

© 2026 SQL Boy. Built for developers.

ContactPrivacyTermsAI Usage PolicyEditorial StandardsAboutRSS Feed