Guide · Engines
A SQLite browser
Read this when you have a .db or .sqlite file to look inside, from an app, a phone backup or a test suite, and want a desktop client for it. SQLite has no server to reach, so the hard parts are elsewhere: the file and the files beside it, locks shared with the app that owns it, and a schema that changes in fewer ways than you expect. The first half is SQLite. The second half is what Seqora does with a SQLite file and what it doesn't.
A database is a file, and sometimes three
A SQLite database is one file that starts with the 16 bytes SQLite format 3, by the file format page. The extension means nothing to SQLite. .db, .sqlite and .sqlite3 are conventions.
A database in WAL mode has two more files beside it, -wal and -shm. Recent commits can live in the -wal file until a checkpoint moves them into the main file, so the WAL page says the -wal file has to travel with the database. Copying only app.db out of a running app can lose the last writes.
To copy a database that is in use, use VACUUM INTO 'copy.db' (SQLite 3.27.0 and later), the backup API, or .backup in the sqlite3 shell. Copying the file during a write can produce a corrupt copy, by How to corrupt a database.
Don't open a database over a network share while something else writes to it. File locking on network filesystems is known to fail, and the SQLite team's page recommends a client/server engine for that, or keeping all access on the machine that holds the file. WAL needs shared memory, so it doesn't work across machines at all.
One writer at a time
SQLite lets many readers in and one writer. A second writer gets SQLITE_BUSY, which SQLite's message calls database is locked, by the result codes. A busy timeout makes a connection wait that many milliseconds for the lock before it gives up. In WAL mode readers and the writer don't block each other, but there is still only one writer.
That matters for a GUI. A client that holds a write transaction open on your app's database locks the app out of writing until the client commits or closes.
Foreign keys are off by default
SQLite parses REFERENCES and doesn't enforce it until a connection runs PRAGMA foreign_keys = ON, and the setting lasts only for that connection, by the foreign key page. An app that forgot it may have written orphan rows for years. PRAGMA foreign_key_check lists them, one row per violation.
ALTER TABLE does four things
ALTER TABLE can rename a table, rename a column (3.25.0), add a column and drop a column (3.35.0). An added column can't be a PRIMARY KEY or UNIQUE, and can't be NOT NULL without a default.
Anything else, such as changing a column's type or adding a constraint, means building a new table. The docs give twelve steps: turn foreign keys off, begin, create the new table, copy the rows, drop the old one, rename the new one, recreate the indexes, triggers and views, run PRAGMA foreign_key_check, commit, and turn foreign keys back on. The order matters. Renaming the old table first breaks the references to it.
Types are suggestions
A column's declared type is a preference. Any column except an INTEGER PRIMARY KEY can hold a value of any type, by the datatypes page, so an INTEGER column can hold 'n/a'. A STRICT table, from SQLite 3.37.0, refuses a value that doesn't match its column, by the STRICT tables page. A grid that shows every value of a column as the declared type is hiding something.
No users, no grants
SQLite has no users, passwords or GRANT. The omitted features page says the file's permissions are the only access control. Whoever can read the file can read every row.
Plans
EXPLAIN QUERY PLAN describes the strategy, which index each step uses and which table it scans, and its output format can change between releases, by the query plan page. ANALYZE stores statistics in sqlite_stat1 for the planner, and the ANALYZE page recommends running PRAGMA optimize from time to time.
What to look for in a client
- It can open a file read-only, so looking never takes a write lock.
- It turns foreign keys on for its own writes.
- It does the twelve steps for a change
ALTER TABLEcan't make, and keeps the triggers, indexes andCHECKconstraints it rebuilds. - It shows a value as stored, not as the declared type says it should be.
- It doesn't create an empty database when you mistype a path.
Seqora on SQLite
A SQLite connection in Seqora is a Database file, not a host, and Seqora stores only its path. There is no TLS and no SSH, because there is no server.
- Opening. Pick the file with
Browse…, double-click a.sqlitefile, drop one on the window, or press ⌘O or CtrlO. Asqlite:URL, or Prisma'sfile:./dev.db, switches the dialog to SQLite with that file. Seqora opens a file that exists and never creates one. - Locked means read-only. A locked connection opens the file read-only, with
query_onlyon. The SQL editor turnsforeign_keyson, and waits up to 250 ms for another writer's lock. - One file per connection. The editor runs against the file's
mainschema.ATTACHandDETACHare refused.PRAGMAruns from an allow-list: the schema-reading ones, such astable_info,index_listandforeign_key_check, are allowed, settings that change the file are not, andforeign_keyscan be set only while the connection is unlocked. - Edits. Grid edits wait in
Pending changesfor a review and apply in one transaction. A table needs a primary key or a unique index to be edited.Reverttakes a grid write back. See Edit data. - Schema changes (Pro). Design mode on SQLite is the twelve-step rebuild, in one transaction, with foreign key enforcement off during the copy and checked before the commit. The new table is written from the old one's
CREATEtext, soCHECKconstraints, collations,AUTOINCREMENTand its counter, generated columns, triggers, and partial or expression indexes come across. The dry run runs the same transaction and rolls it back. - Plans (Pro). The Plan tab shows
EXPLAIN QUERY PLAN, which has estimates and no timings. On an index's page,With and without this indexplans the query on an in-memory copy of the schema and statistics, and counts rows visited fromsqlite_stat1.
The ER diagram, the database brief and watching a table work as on every engine. Sample coffee shop, which every install includes, is a SQLite database.
Not on SQLite, with the reason:
- The index advisor. SQLite counts no index usage.
- The session recorder. SQLite keeps no statement statistics.
Access, routine and partition pages. SQLite has no users, routines or partitions.- The lock forecast, undo from the SQL editor and
View as role, which are PostgreSQL only.
MySQL, MariaDB, SQLite and SQL Server has the full table.
Caveats
- Parameters must be bound. A statement with a placeholder in it gets
Unbound SQL parameters are not supported. Supply explicit values. Reverton SQLite covers grid edits. A write from the SQL editor can't be taken back in Seqora.- No SQLite version is certified yet. Seqora carries its own SQLite library, and the target is 3.51.3.