Detach Database in SQLite

SQLite Detach Database To detach the alias-named database from an attached database connection, the SQLite DETACH DATABASE statement is used. It only detaches a single alias at a time in case if the same database file has been attached with multiple aliases. However, this statement cannot detach the Main and temp databases. It destroys the databases within the in-memory or temporary database, thus causing the loss of content.

Syntax:

DETACH DATABASE 'Alias-Name'  

Example:

DETACH DATABASE 'DBExample';

Explanation: Here example.db is an already existing database and ‘DBExample’ represents the alias_name. The database will be detached after the execution of the above query. It can be verified using the command “.databases”.

Please follow and like us:
Content Protection by DMCA.com