{
    "mode": "man",
    "parameter": "sqldiff",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/sqldiff/1/json",
    "generated": "2026-05-30T05:14:31Z",
    "synopsis": "sqldiff [options] database1.sqlite database2.sqlite",
    "sections": {
        "NAME": {
            "content": "sqldiff - sqlite3 database difference utility\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "sqldiff [options] database1.sqlite database2.sqlite\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The  sqldiff  binary  is a command-line utility program that displays the differences between\nSQLite databases.  The usual output is an SQL script  that  will  transform  database1.sqlite\n(the \"source\" database) into database2.sqlite (the \"destination\" database).\n\nThe  sqldiff  utility  works  by  finding rows in the source and destination that are logical\n\"pairs\". The default behavior is to treat two rows as pairs if they are in  tables  with  the\nsame  name and they have the same rowid, or in the case of a WITHOUT ROWID table if they have\nthe same PRIMARY KEY. Any differences in the content of paired rows are  output  as  UPDATEs.\nRows  in the source database that could not be paired are output as DELETEs. Rows in the des‐\ntination database that could not be paired are output as INSERTs.\n\nThe --primarykey flag changes the pairing algorithm slightly so that the schema-declared PRI‐\nMARY KEY is always used for pairing, even on tables that have a rowid. This is often a better\nchoice for finding differences, however it can lead to missed differences in the case of rows\nthat have one or more PRIMARY KEY columns set to NULL.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "--changset FILE\nDo not write changes to standard output. Instead, write a (binary) changeset file into\nFILE.  The changeset can be interpreted using the sessions extension to SQLite.\n\n--lib LIBRARY, -L LIBRARY\nLoad the shared library or DLL file LIBRARY into SQLite prior to computing the differ‐\nences.  This  can  be used to add application-defined collating sequences that are re‐\nquired by the schema.\n",
            "subsections": [
                {
                    "name": "--primarykey",
                    "content": "Use the schema-defined PRIMARY KEY instead of the rowid to pair rows in the source and\ndestination database. (See additional explanation below.)\n",
                    "long": "--primarykey"
                },
                {
                    "name": "--schema",
                    "content": "Show only differences in the schema not the table content\n",
                    "long": "--schema"
                },
                {
                    "name": "--summary",
                    "content": "Show how many rows have changed on each table, but do not show the actual changes\n\n--table TABLE\nShow only the differences in content for TABLE, not for the entire database\n",
                    "long": "--summary"
                },
                {
                    "name": "--transaction",
                    "content": "Wrap SQL output in a single large transaction\n\n--vtab Add support for handling FTS3, FTS5 and rtree virtual tables. See below for details.\n",
                    "long": "--transaction"
                }
            ]
        },
        "LIMITATIONS": {
            "content": "The  sqldiff utility is unable to compute differences for rowid tables for which the rowid is\ninaccessible. An example of a table with an inaccessible rowid is:\n\nCREATE TABLE inaccessiblerowid(\n\"rowid\" TEXT,\n\"oid\" TEXT,\n\"rowid\" TEXT\n);\n\nThe sqldiff utility does not (currently) display differences in TRIGGERs or VIEWs.\n\nBy default, differences in the schema or content of virtual tables are not reported on.\n\nHowever, if a virtual table implementation creates real  tables  (sometimes  referred  to  as\n\"shadow\"  tables)  within  the database to store its data in, then sqldiff.exe does calculate\nthe difference between these. This can have surprising effects if the resulting SQL script is\nthen  run  on  a database that is not exactly the same as the source database. For several of\nSQLite's bundled virtual tables (FTS3, FTS5, rtree and others), the  surprising  effects  may\ninclude corruption of the virtual table content.\n\nIf  the  --vtab option is passed to sqldiff, then it ignores all underlying shadow tables be‐\nlonging to an FTS3, FTS5 or rtree virtual table and instead includes the virtual  table  dif‐\nferences directly.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "sqlite3(1).\n\n\n\n2018-05-10                                   sqldiff(1)",
            "subsections": []
        }
    },
    "summary": "sqldiff - sqlite3 database difference utility",
    "flags": [
        {
            "flag": "",
            "long": "--primarykey",
            "arg": null,
            "description": "Use the schema-defined PRIMARY KEY instead of the rowid to pair rows in the source and destination database. (See additional explanation below.)"
        },
        {
            "flag": "",
            "long": "--schema",
            "arg": null,
            "description": "Show only differences in the schema not the table content"
        },
        {
            "flag": "",
            "long": "--summary",
            "arg": null,
            "description": "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"
        },
        {
            "flag": "",
            "long": "--transaction",
            "arg": null,
            "description": "Wrap SQL output in a single large transaction --vtab Add support for handling FTS3, FTS5 and rtree virtual tables. See below for details."
        }
    ],
    "examples": [],
    "see_also": [
        {
            "name": "sqlite3",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/sqlite3/1/json"
        }
    ]
}