# sqldiff(1) - man - phpMan

[sqldiff(1)](https://www.chedong.com/phpMan.php/man/sqldiff/1/markdown)                             General Commands Manual                            [sqldiff(1)](https://www.chedong.com/phpMan.php/man/sqldiff/1/markdown)



## NAME
       sqldiff - sqlite3 database difference utility

## SYNOPSIS
       **sqldiff** [_options_] _database1.sqlite_ _database2.sqlite_

## DESCRIPTION
       The  **sqldiff**  binary  is a command-line utility program that displays the differences between
       SQLite databases.  The usual output is an SQL script  that  will  transform  _database1.sqlite_
       (the "source" database) into _database2.sqlite_ (the "destination" database).

       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 des‐
       tination database that could not be paired are output as INSERTs.

       The **--primarykey** flag changes the pairing algorithm slightly so that the schema-declared PRI‐
       MARY 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.

## 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 differ‐
              ences.  This  can  be used to add application-defined collating sequences that are re‐
              quired by the schema.

### --primarykey
              Use the schema-defined PRIMARY KEY instead of the rowid to 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
       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.

       If  the  **--vtab** option is passed to **sqldiff**, then it ignores all underlying shadow tables be‐
       longing to an FTS3, FTS5 or rtree virtual table and instead includes the virtual  table  dif‐
       ferences directly.

## SEE ALSO
       [**sqlite3**(1)](https://www.chedong.com/phpMan.php/man/sqlite3/1/markdown).



                                             2018-05-10                                   [sqldiff(1)](https://www.chedong.com/phpMan.php/man/sqldiff/1/markdown)
