Command 1. Sort databases: vacuum
The vacuum command is an extended function of SQLite. It imitates the same commands in PostgreSQL. If vacuum is called with a table name or index name, the table or index will be sorted. In SQLite 1.0, the vacuum command callsGdbm_reorganize ()Sort back-end database files.
Gdbm backend is removed from SQLite 2.0.0, and vacuum is invalid. In version 2.8.1, vacuum is implemented again. The index name or table name is ignored.
When an object (table, index, or trigger) in the database is revoked, a blank space is left. It makes the database larger than the required size, but can speed up the insertion. Real-time insertion and deletion can make the database file structure messy and slow the access to the database content. The vacuum Command copies the master database file to the temporary database and reloads it from the temporary database to the master database to sort out the database files. This will remove blank pages, arrange the table data adjacent to each other, and sort out the database file structure. You cannot perform the preceding operations on the attached database file.
This command does not work if active transactions exist. This command is invalid for the in-memory database.
In sqlite3.1, the vacuum command can be replaced by the auto-vacuum mode.Auto_vacuum PragmaEnable this mode.
2. Export Database:. Dump
. Output file. SQL
. Dump
. Output stdout
3. Import Database:. Read and. Import
. Read File. SQL
. Import [Table]