The journal file will be generated for any database modification operation. However, if the file is executed according to the normal process, it will be automatically deleted, almost instantly, so we cannot see it, if we see this file and the program has been executed, the transaction is rolled back! Generation reason
Any database modification operation will generate a journal file, but if the file is executed according to the normal process, it will be automatically deleted, almost instantly, so we cannot see it, if we see this file and the program has been executed, the transaction is rolled back !!
There are the following causes for journal files:
1)
Begin transaction;
Commit transaction;
No pairing, resulting in-journal file generation
Begintransaction is executed;
Committransaction not executed;
2)
After using sqlite3_prepare (db, SQL, strlen (SQL), & stmt, & tail,
Sqlite3_finalize (stmt) must be used to release stmt.
For other matching usage in sqlite.
Solution:
1)
You generated. db-journal because your transaction is rolled back. (there may be many reasons)
It can be recovered in the next data query operation.
You can use timeout in your database operations so that you can predict that busy time will wait for timeout time.
The. db-journal file is only available in small quantities.
Journal temporary Archive
The answer is Rollback. In other words, when data fails to be written to the database, the journal file is used to restore the original data to ensure data integrity and consistency. If the database is written for a long time or frequently, the journal file will be restarted the next time because the system (host) is unstable or suddenly loses power. if the journal file exists, when the SQLite database is enabled, if there is a journal file, the database will be Rollback action (restore) (details: http://www.sqlite.org/atomiccommit.html ). However, sometimes the power of the system (host) is unstable or sudden power failure will damage the journal file, resulting in the failure to enable the SQLite database [problem 1]. You must (manually) delete the journal file before the SQLite database can be enabled again.
Currently, two methods are available:
Method 1:
When the system is enabled for the first time after the system is started or the SQLite database is used each time, check whether a journal file exists. If yes, the journal file is automatically deleted through the program.
However, this problem occurs because automatic deletion of the journal file does not affect Rollback and data integrity and consistency cannot be guaranteed. Drawback 2: sometimes the program cannot be automatically deleted (for example, the journal file is seriously damaged), and the above problem (the database cannot be started) [problem 1] occurs again.
Method 2:
Run the "PRAGMAjournal_mode = OFF" command to disable automatic journal temporary archiving.
However, when a database is written, the SQLite database cannot guarantee data integrity and consistency in the event of an unexpected situation. Disadvantage 2: When journal_mode is set to OFF, the Transaction mode (Transaction) cannot be used for operations.
Disadvantage 2 of the second method: If you need to use the Transaction mode (Transaction) for operations, you can use the "PRAGMA journal_mode = DELETE" command to modify the original journal mode (journal_mode ), you can use the Transaction mode (Transaction ).