IOS-useful SQLite commands and knowledge (not commonly used)

Source: Internet
Author: User
Tags import database
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]

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.