Compare SQL queries online

Two queries that point at a different table and columns, with a new sort order. Paste your own SQL or schema dumps to compare them. Tips for SQL

Original
0 lines
Drop to load into original
Changed
0 lines
Drop to load into changed
−0+0
Original
Changed

About this SQL comparison

A query that returns different results often differs by one column name, one filter or one ORDER BY direction. An SQL diff shows those differences next to each other, so you do not have to read both queries word by word.

It works just as well for schema migrations and database dumps: compare two CREATE TABLE scripts to see which columns or indexes changed.

What changed in this sample

  • Columns id, name, email became user_id, user_name, user_email.
  • The table changed from users to customers, and status to account_status.
  • The sort order flipped from ASC to DESC, and the count alias changed to totalUsers.

Tips for comparing SQL

Ignore keyword case
One version writes SELECT, the other select? Turn on Ignore case.
Compare schema dumps
Dump the schema from both databases (for example with mysqldump --no-data or pg_dump --schema-only) and compare the files.
Column lists in any order
Put one column per line and use Sort lines before comparing to check whether two column lists match.
Reformatted queries
If a formatter changed the line breaks, Ignore whitespace and Ignore blank lines show only the real differences.

How to compare SQL online

  1. Paste the older version into Original and the newer one into Changed, or open a file on each side.
  2. Check that the syntax menu says SQL, then pick split or unified view.
  3. Step through the changes with the arrows or Alt ↓, and use Settings for options such as ignoring blank lines.
  4. Save the comparison in your browser, share a link, or download it as a .diff, HTML or PDF.

SQL comparison: questions

Can I compare two database schemas?

Yes, as text. Export each schema as SQL and paste or open the two files. Changed tables, columns and indexes are highlighted.

Does it connect to my database?

No. It never connects to anything; it only compares the SQL text you give it.

Which SQL dialects are supported?

Any. Highlighting covers standard SQL keywords, and the comparison itself works on any text.