4. The WAL File
...
The WAL file exists for as long as any database connection has the database open.
Usually, the WAL file is deleted automatically when the last connection to the database closes.
However, if the last process to have the database open exits without cleanly shutting down the database connection, or if the
SQLITE_FCNTL_PERSIST_WAL file control is used, then the WAL file might be retained on disk after all connections to the database have been closed. The WAL file is part of the persistent state of the database and should be kept with the database if the database is copied or moved. If a database file is separated from its WAL file, then transactions that were previously committed to the database might be lost, or the database file might become corrupted. The only safe way to remove a WAL file is to open the database file using one of the
sqlite3_open() interfaces then immediately close the database using
sqlite3_close().
The
WAL file format is precisely defined and is cross-platform.