SQLite learning Manual (memory database)

Source: Internet
Author: User

I. Memory Database:

In SQLite, databases are usually stored in disk files. However, in some cases, we can keep the database in the memory. The most common method is to pass ": Memory:" To the database file name parameter when calling sqlite3_open (), for example:
Rc = sqlite3_open (": Memory:", & DB );
After the above functions are called, no disk files are generated. Instead, a new database is successfully created in pure memory. Because the database is not persistent, the database disappears immediately after the current database connection is closed. Note that although multiple database connections can be used to create memory databases, they are different databases and have no relationship with each other. In fact, we can also use the attach command to attach a memory database to the current connection like other common databases, such:
Attach database': Memory:'As aux1;

Ii. Temporary database:

when you call the sqlite3_open () function or execute the attach command, if the database file parameter is a null string, A new temporary file will be created as the underlying file of the temporary database, such as:
rc = sqlite3_open ("", & dB);
or
attach database ''as aux2;
similar to the memory database, the temporary databases created by the two databases are also independent. After the connection is closed, the temporary database will automatically disappear, the underlying files will also be deleted automatically.
although the disk file is created to store data information in the temporary database, the temporary database actually resides in the memory like the memory database. The only difference is that, when the data volume in the temporary database is too large, SQLite writes some data in the temporary database to the disk file to ensure that more memory is available for other operations, memory databases always store data in the memory.

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.