Compare two SQL queries

Compare two SQL schemas and list added, removed, and changed objects.

freeworks offlinenothing uploaded
ToolSQL Diff
Input
Output
Put this on your own site

The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.

Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.

Preview

How it works

Schema descriptions are normalized into tables, columns, constraints, and indexes; set differences then produce a review report or migration draft. The result is not applied to a live database.

  • Normalization ignores declaration-order noise.
  • A rename map is needed to distinguish rename from drop plus add.

Worked example

Compare SQL Queries
Compare two SELECT queries to find structural differences
Input
											Input1: SELECT name, email FROM users WHERE active = true
Input2: SELECT name, email, age FROM users WHERE active = true AND age > 18
										
Output
												Type      Section  Detail
--------  -------  ------------------------------------------------------------------
modified  SELECT   SELECT changed from "NAME, EMAIL" to "NAME, EMAIL, AGE"
modified  WHERE    WHERE changed from "ACTIVE = TRUE" to "ACTIVE = TRUE AND AGE > 18"
											

When to use this

Drift checks, migration reviews, and DBA release planning compare schemas.

Edge cases

  • A renamed column can look like removal and addition.
  • Textually different defaults can be semantically equivalent.
  • Simplified exports may omit index options.

References