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.