Attaching Databases

Important

Consult Sqlite documentation .

You can attach and detach other database files to the current database connection from the System menu or by executing SQL commands in the SQL Editor. Every attached database is identified by its unique name (prefix). The names 'main' and 'temp' refer to the main database and the database used for temporary tables. These cannot be detached. When creating tables or running queries you should access database objects with full prefixed naming convention:

SELECT * FROM newdb.sometable;

However, a view or an index or a trigger can only reference entities in the same database, so when creating a view or an index or a trigger, only the name of the view or index or trigger should be prefixed.

CREATE INDEX newdb.newindex ON sometable (somecolumn);

Data can be transferred from one database to another by using Create Table... to create a table in one database by selecting from another database.

It is possible to open the same database with two different names: sqliteman cannot in general detect this. It is possible by checking inode numbers to determine whether two filenames refer to the same file on a local filesystem, but if there are remote filesystems mounted, an inode number is no longer a unique identifier and may not even be available. If the same database is opened with two different names, sqliteman may behave unpredictably.

Attaching a database can fail with an error like

malformed database schema ... view .... cannot reference objects in database main Unable to fetch row

This is caused by creating a view on a table or a view with its name qualified by its database name. Using the Create View dialog in versions of sqliteman before 1.8.1 would create such views.

To fix such a database, do the following:-