ATTACH DATABASE
ATTACH DATABASE is a SQL statement in the SQLite Specific category. SQLite: connects another database file to the current connection, allowing cross-database queries. The syntax is ATTACH [DATABASE] 'file_path' AS alias;. It returns attached database. A typical example: ATTACH DATABASE 'backup.db' AS backup; -- Query across databases: SELECT * FROM main.users UNION SELECT * FROM backup.users; -- DETACH: DETACH DATABASE backup; -- Default aliases: main (primary), temp (temporary) A close relative is AUTOINCREMENT (SQLite), which sQLite: unlike AUTO_INCREMENT in MySQL, only INTEGER PRIMARY KEY columns auto-increment. AUTOINCREMENT guarantees unique increasing IDs. A close relative is ROWID / _ROWID_, which sQLite: every row has an implicit 64-bit ROWID. INTEGER PRIMARY KEY becomes an alias for ROWID. A close relative is PRAGMA, which sQLite: special commands to query/set database configuration, metadata, and behavior. More about this category: SQLite-specific features — AUTOINCREMENT, ATTACH, VACUUM, PRAGMA, ROWID. Related SQLite Specific entries: AUTOINCREMENT (SQLite), ROWID / _ROWID_, PRAGMA, VACUUM (SQLite), EXPLAIN QUERY PLAN (SQLite), JSON Functions (SQLite), CREATE VIRTUAL TABLE (FTS5), LIMIT/OFFSET with ORDER BY (SQLite).