sqldiff(1)
π NAME π
sqldiff β the sqlite3 database difference utility, aka the girl who will literally tell you exactly what changed between two databases π¦β¨
πΈ SYNOPSIS πΈ
sqldiff [options] database1.sqlite database2.sqlite
β¨ DESCRIPTION β¨
okay so bestie, listen. sqldiff is a command-line utility program that displays the differences between SQLite databases. and the usual output? it's an SQL script that will transform database1.sqlite (the "source" database) into database2.sqlite (the "destination" database). like, it hands you the glow-up instructions for your database. periodt π
here's the cute lil algorithm, no cap: the sqldiff utility works by finding rows in the source and destination that are logical "pairs". The default behavior is to treat two rows as pairs if they are in tables with the same name and they have the same rowid, or β in the case of a WITHOUT ROWID table β if they have the same PRIMARY KEY. Any differences in the content of paired rows are output as UPDATEs. Rows in the source database that could not be paired are output as DELETEs. Rows in the destination database that could not be paired are output as INSERTs. like it's giving matchmaker but make it SQL π«Ά
The --primarykey flag changes the pairing algorithm slightly so that the schema-declared PRIMARY KEY is always used for pairing, even on tables that have a rowid. This is often a better choice for finding differences, however it can lead to missed differences in the case of rows that have one or more PRIMARY KEY columns set to NULL. (see the extra explanation below, iykyk π)
π OPTIONS π
--changset FILEβ Do not write changes to standard output. Instead, write a (binary) changeset file into FILE. The changeset can be interpreted using the sessions extension to SQLite. π¦--lib LIBRARY,-L LIBRARYβ Load the shared library or DLL file LIBRARY into SQLite prior to computing the differences. This can be used to add application-defined collating sequences that are required by the schema. π--primarykeyβ Use the schema-definedPRIMARY KEYinstead of therowidto pair rows in the source and destination database. (See additional explanation below.) π--schemaβ Show only differences in the schema not the table content ποΈ--summaryβ Show how many rows have changed on each table, but do not show the actual changes π--table TABLEβ Show only the differences in content for TABLE, not for the entire database π―--transactionβ Wrap SQL output in a single large transaction π--vtabβ Add support for handling FTS3, FTS5 and rtree virtual tables. See below for details. π§
π LIMITATIONS π
ngl, there are some things she just cannot do, and we respect her for knowing her limits.
The sqldiff utility is unable to compute differences for rowid tables for which the rowid is inaccessible. An example of a table with an inaccessible rowid is:
CREATE TABLE inaccessible_rowid(
"rowid" TEXT,
"oid" TEXT,
"_rowid_" TEXT
);
The sqldiff utility does not (currently) display differences in TRIGGERs or VIEWs. π
By default, differences in the schema or content of virtual tables are not reported on. π«₯
However, if a virtual table implementation creates real tables (sometimes referred to as "shadow" tables) within the database to store its data in, then sqldiff.exe does calculate the difference between these. This can have surprising effects if the resulting SQL script is then run on a database that is not exactly the same as the source database. For several of SQLite's bundled virtual tables (FTS3, FTS5, rtree and others), the surprising effects may include corruption of the virtual table content. π like bestie that is NOT the vibe.
β οΈ fr fr, read that shadow-table paragraph twice. corruption is not cute.
If the --vtab option is passed to sqldiff, then it ignores all underlying shadow tables belonging to an FTS3, FTS5 or rtree virtual table and instead includes the virtual table differences directly. slay, problem solved β¨
π SEE ALSO π
okay that's the whole page, mwah π this was the sqldiff(1) page from the General Commands Manual, dated 2018-05-10 β go forth and diff your databases, bestie, you're the main character now π
π¦ where this page comes from
- debian bookworm: sqlite3 3.40.1-2+deb12u2 Β· LicenseRef-public-domain
- debian trixie: sqlite3-tools 3.46.1-7+deb13u2 Β· LicenseRef-public-domain
- ubuntu jammy: sqlite3 3.37.2-2 Β· LicenseRef-public-domain
- ubuntu jammy: sqlite3 3.37.2-2ubuntu0.8 Β· LicenseRef-public-domain
- ubuntu noble: sqlite3 3.45.1-1ubuntu2 Β· LicenseRef-public-domain
- ubuntu noble: sqlite3 3.45.1-1ubuntu2.8 Β· LicenseRef-public-domain
- ubuntu questing: sqlite3-tools 3.46.1-8
- ubuntu questing: sqlite3-tools 3.46.1-8ubuntu0.1
- ubuntu resolute: sqlite3-tools 3.46.1-9 Β· LicenseRef-public-domain
- ubuntu resolute: sqlite3-tools 3.46.1-9ubuntu0.3 Β· LicenseRef-public-domain
- ubuntu stonking: sqlite3-tools 3.53.4-2 Β· LicenseRef-public-domain
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms