0

I have a few SQLite databases and I'm using DB Visualizer Free to view the tables. I would like to create selects statements with joins between the sqlite databases. From the SQLite documentation I can see that the DB can be linked using the ATTACH http://www.sqlite.org/lang_attach.html statement. I can't for the life of me get this to work.

In DbVisualizer I have created two connections A (A.db) and B (B.db). A has a table called TABLE_A and B has a TABLE_B. From other posts I have tried to do the following:

    ATTACH DATABASE 'A' AS 'DB1';
    SELECT * FROM DB1.TABLE_A;

I'm getting the following error from DB Visualizer:

[SELECT - 0 row(s), 0.000 secs]  [SQLITE_ERROR] SQL error or missing database (no such table: DB1)

I have tried to take the single quote off both A and DB1 and the combination of the two, but nothing seems to work. I have also tried to change A to A.db and that doesn't work.

I don't think the ATTACH command is linking correctly.

1 Answer 1

1

ATTACH will happily create a new database if the file does not yet exist.

The file name 'A' specifies a file named "A" in the current directory.

You should specify the full path and the full file name:

ATTACH 'C:\some\where\A.db' AS db1;
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks CL! That was very simple.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.