Skip to content

Attaching Databases

Attaching databases allows you to write queries and commands that work across multiple database files at once.

Attach database dialog

Attach database button To attach a database to your current file, click the add () button in the lower-left of the window and select Attach Database….

In the dialog that appears, you can choose a database file to be attached. You'll also need to give it a name. This is how you will refer to it in any SQL statements you write. It'll also show in the sidebar before any table or view names so that you can tell them apart from tables in the current database.

Info

For details on working with attached databases, see the SQLite documentation.

Detaching databases

Select the database you want to detach. Then either right-click on it and select "Detach", or select Database ▸ Detach Selected…

Info

You can't detach the main database, that's the file you've got open.

Security notes

As part of macOS security protections, Base can only open files which you have explicitly selected.

Because of these protections, attempting to run an ATTACH DATABASE command will only work if Base already has the other database open. You can still attach databases using the user interface as described above.

Note

The protecting of access to files is part of a technology called the App Sandbox. It's designed to stop apps from accessing files without your permission.