Name

DETACH DATABASE — Detach a database file

Syntax

image with no caption

Common Usage

DETACH DATABASE database_name;

Description

The DETACH DATABASE command detaches and dissociates a named database from a database connection. If the same file has been attached multiple times, this will only detach the named attachment. If the database is an in-memory or temporary database, the database will be destroyed and the contents will be lost.

You cannot detach the main or temp databases. The DETACH command will fail if issued inside a transaction.

See Also

ATTACH DATABASE

Get Using SQLite now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.