HiveBrain v1.2.0
Get Started
← Back to all entries
debugsqlMinor

Can sqlite dump database schema in a fixed order?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
dumpcanordersqlitedatabasefixedschema

Problem

I am using SQLiteStudio 3.0.7 to dump the database schema regularly for versioning purposes and it seems to change the order of the table definitions at random. This wreaks havoc on the diffs as even a small change like adding one or two additional columns seems to result in wild diffs all over the place. A side by side comparision can result in a whole table being list out separately when it is just the line difference that should show.

Can SQLiteStudio be configured to do that correctly., or can sqlite itself do the same schema export in a fixed formatted manner?

Solution

SQLiteStudio sorts the database objects by type (table, index, trigger, view), but inside each group, sorts them randomly.
(If you consider this a bug, report it.)

The sqlite3 shell dumps tables in the order in which they are stored in the sqlite_master table, which is typically the same order in which they were (re)created.

Context

StackExchange Database Administrators Q#128839, answer score: 2

Revisions (0)

No revisions yet.