Name
ATTACH DATABASE — Attach a database file
Syntax
Common Usage
ATTACH DATABASE 'filename
' ASdatabase_name
;
Description
The ATTACH
DATABASE
command associates the database file
with the current database connection under the
logical database name filename
. If the database file database_name
does not exist, it will be created. Once attached,
all references to a specific database are done via the logical
database name, not the filename. All database names must be
unique, but (when shared cache mode is not enabled) attaching
the same filename multiple times under different database names
is properly supported.filename
The database name main
is reserved for the primary
database (the one that was used to create the database
connection). The database name temp
is reserved for the database that holds
temporary tables and other temporary data objects. Both of these
database names exist for every database connection.
If the filename :memory:
is given, a new
in-memory database will be created and attached. Multiple
in-memory databases can be attached, but they will each be
unique. If an empty filename is given ( ''
), a temporary file-backed database will be created. Like an in-memory database, each database is unique and all temporary databases are automatically deleted when they are closed. Unlike an in-memory database, file-based temporary databases can grow to large sizes without consuming ...
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.