6

When I create a SQLite memory database - how do I delete it when I'm finished? Is it automatically released when the script ends and closes the connection?

$pdo = new PDO('sqlite::memory:');
2
  • 3
    sqlite.org/inmemorydb.html Commented Feb 21, 2012 at 20:33
  • I suspect you'd want to destroy the PDO object ($pdo = NULL;) to get the memory released before script execution ends (if you're using it in a lengthy unit testing suite, for example) Commented Feb 21, 2012 at 20:38

2 Answers 2

15

The most common way to force an SQLite database to exist purely in memory is to open the database using the special filename ":memory:"... ...When this is done, no disk file is opened. Instead, a new database is created purely in memory. The database ceases to exist as soon as the database connection is closed. Every :memory: database is distinct from every other. So, opening two database connections each with the filename ":memory:" will create two independent in-memory databases. - SQLite

Sign up to request clarification or add additional context in comments.

Comments

3

Yes, that's what happens.

1 Comment

You could append a link to an authoritative reference.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.