ATTACH DATABASE

Add a database to the current connection

Synopsis:

ATTACH [DATABASE] database-filename AS database-name

Description:

The ATTACH DATABASE statement adds another database
file to the current database connection. If the filename contains
punctuation characters, it must be placed inside quotation marks. The names main and
temp refer to the main database and the database used for
temporary tables. These cannot be detached. Attached databases
are removed using the DETACH DATABASE
statement.

You can read from and write to an attached database, and you
can modify the schema of the attached database.

You cannot create a new table with the same name as a table in an attached database, but you can
attach a database that contains tables whose names are duplicates of tables in the
main database. It is also permissible to attach the same database file multiple
times.

Tables in an attached database can be referred to using the syntax
database-name.table-name. If an attached table doesn't have a
duplicate table name in the main database, it doesn't require a database name
prefix. When a database is attached, all of its tables that don't have duplicate
names become the default table of that name. Any tables of that name attached
afterwards require the table prefix. If the default table of a given name is
detached, then the last table of that name attached becomes the new default.