SQLite Detach Database

The SQLite DETACH DATABASE statement is used to detach the alias-named database from a database connection which was previously attached by using ATTACH statement.

If the same database file has been attached with multiple aliases, then DETACH command will disconnect only given name and rest of the attachment will still continue. Main and temp databases cannot be detached.

Note
Note: The databases within the in-memory or temporary database, will be destroyed completely and content will be lost.

Syntax:

snippet
DETACH DATABASE 'Alias-Name'

Let's take an example to demonstrate how to detach an attached alias database. Here, we have a attached database "JavaTpoint".

SQLite Detach database 1

Detach 'JavaTpoint' from JTP.db:

snippet
DETACH DATABASE 'JavaTpoint';
SQLite Detach database 2

Database is detached now. You can see it by using ".databases" command.

SQLite Detach database 3
Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents