Less of a tutorial, more to point out another option which doesn't seem to have a mention anywhere on here yet....
I was searching for options to create a backup copy of an SQLite database. There are already options detailed here, and here, for example.
But another option that seemed quite attractive was to use VACUUM INTO, as detailed on sqlite.org at https://www.sqlite.org/lang_vacuum.html
The bit that stood out to me was;
Usage is pretty simple with the SQL library:
Notes:
1. VACUUM INTO requires SQLite version 3.27.0 or later (@Claudio Oliveira handily keeps a list of the latest SQLite JDBC library versions here)
2. VACUUM can not be executed from within a transaction.
I was searching for options to create a backup copy of an SQLite database. There are already options detailed here, and here, for example.
But another option that seemed quite attractive was to use VACUUM INTO, as detailed on sqlite.org at https://www.sqlite.org/lang_vacuum.html
The bit that stood out to me was;
It works when the database is open, with live *.wal files for example, and handily produces just a single backup file that's been shrunk to its minimum size.The VACUUM command with an INTO clause is an alternative to the backup API for generating backup copies of a live database
Usage is pretty simple with the SQL library:
Backup SQLite using VACUUM INTO...:
Dim filePath As String = "C:\Database"
Dim fileName As String = "myDB.db"
Dim backupPath As String = "C:\DBBackup\myDB-backup.db" 'backupPath must include the filename
Dim sql As SQL
sql.InitializeSQLite(filePath, fileName, False)
sql.ExecNonQuery2("VACUUM INTO ?", Array(backupPath))
Notes:
1. VACUUM INTO requires SQLite version 3.27.0 or later (@Claudio Oliveira handily keeps a list of the latest SQLite JDBC library versions here)
2. VACUUM can not be executed from within a transaction.
Last edited: