- SQLite - DISTINCT Keyword
- SQLite - HAVING Clause
- SQLite - GROUP By Clause
- SQLite - ORDER By Clause
- SQLite - LIMIT Clause
- SQLite - GLOB Clause
- SQLite - LIKE Clause
- SQLite - DELETE Query
- SQLite - UPDATE Query
- SQLite - AND & OR Clauses
- SQLite - WHERE Clause
- SQLite - Expressions
- SQLite - Operators
- SQLite - SELECT Query
- SQLite - INSERT Query
- SQLite - DROP Table
- SQLite - CREATE Table
- SQLite - DETACH Database
- SQLite - ATTACH Database
- SQLite - CREATE Database
- SQLite - Data Type
- SQLite - Syntax
- SQLite - Commands
- SQLite - Installation
- SQLite - Overview
- SQLite - Home
Advanced SQLite
- SQLite - Useful Functions
- SQLite - Date & Time
- SQLite - VACUUM
- SQLite - EXPLAIN
- SQLite - Injection
- SQLite - AUTOINCREMENT
- SQLite - Subqueries
- SQLite - Transactions
- SQLite - Views
- SQLite - TRUNCATE Command
- SQLite - ALTER Command
- SQLite - INDEXED By Clause
- SQLite - Indexes
- SQLite - Triggers
- SQLite - ALIAS Syntax
- SQLite - NULL Values
- SQLite - UNIONS Clause
- SQLite - JOINS
- SQLite - Constraints
- SQLite - PRAGMA
SQLite Interfaces
SQLite Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
SQLite - DETACH Database
SQLite DETACH DATABASE statement is used to detach and dissociate a named database from a database connection which was previously attached using ATTACH statement. If the same database file has been attached with multiple apases, then DETACH command will disconnect only the given name and rest of the attachment will still continue. You cannot detach the main or temp databases.
If the database is an in-memory or temporary database, the database will be destroyed and the contents will be lost.
Syntax
Following is the basic syntax of SQLite DETACH DATABASE Apas-Name statement.
DETACH DATABASE Apas-Name ;
Here, Apas-Name is the same apas, which you had used while attaching the database using ATTACH statement.
Example
Consider you have a database, which you created in the previous chapter and attached it with test and currentDB as we can see using .database command.
sqpte>.databases seq name file --- --------------- ---------------------- 0 main /home/sqpte/testDB.db 2 test /home/sqpte/testDB.db 3 currentDB /home/sqpte/testDB.db
Let s try to detach currentDB from testDB.db using the following command.
sqpte> DETACH DATABASE currentDB ;
Now, if you will check the current attachment, you will find that testDB.db is still connected with test and main .
sqpte>.databases seq name file --- --------------- ---------------------- 0 main /home/sqpte/testDB.db 2 test /home/sqpte/testDB.dbAdvertisements