SQLite Forum

Feature Request: consistent .dump order
Login
It appears that the `.dump` shell command selects tables from
sqlite_master in rowid or insertion order:

    > CREATE TABLE a(id INTEGER);
    > CREATE TABLE b(id INTEGER);
    > .dump

    CREATE TABLE a(id INTEGER);
    CREATE TABLE b(id INTEGER);

    > select * from sqlite_master;
    type        name        tbl_name    rootpage    sql
    ----------  ----------  ----------  ----------  --------------------------
    table       a           a           2           CREATE TABLE a(id INTEGER)
    table       b           b           3           CREATE TABLE b(id INTEGER)

    > DROP TABLE a;
    > CREATE TABLE a(id INTEGER);
    > .dump

    CREATE TABLE b(id INTEGER); -- REVERSE of previous ordering
    CREATE TABLE a(id INTEGER);

    > select * from sqlite_master;
    type        name        tbl_name    rootpage    sql
    ----------  ----------  ----------  ----------  --------------------------
    table       b           b           3           CREATE TABLE b(id INTEGER)
    table       a           a           2           CREATE TABLE a(id INTEGER)

I store some SQLite databases in Git using a filter that calls .dump.
If I happen to change a table or view definition the resulting diff is
unecessarily large and confusing because of the change in output order.

Would it be possible to modify .dump (and .schema) to produce a
consistent output ordering?

Thanks.