How to compare two SQLite databases on Linux

Viewed 34751

Using Linux, I want to compare two SQLite databases that have the same schema. There will be just a few differences.

Is there a tool that would output these differences? Preferably output them to the command line, so that I can grep/sed them.

SQLite uses SQL, so a general SQL tool might also do.

6 Answers

One possibility is to use the sqlite3 command line client to export both databases and then diff the output. For example,

sqlite3 first.sqlite .dump >first.dump
sqlite3 second.sqlite .dump >second.dump
diff first.dump second.dump

There is a free web tool to compare SQLite databases, both schema and data - https://db-merge-tools.net/for-sqlite-online. It works on wasm-compatible browsers, including Firefox and Chromium on Linux.

I am the author of that tool, it is an uno-platform port of my desktop tool for SQLite. Unlike few other online tools I could find - it does not upload your data to the server to generate data diff. However it uploads schema to handle the rest of logic.

Related