简体   繁体   English

SQLite和DbVisualizer:使用“ ATTACH”

[英]SQLite and DbVisualizer: Using 'ATTACH'

I have a few SQLite databases and I'm using DB Visualizer Free to view the tables. 我有一些SQLite数据库,并且正在使用DB Visualizer Free查看表。 I would like to create selects statements with joins between the sqlite databases. 我想创建与SQLite数据库之间的联接的selects语句。 From the SQLite documentation I can see that the DB can be linked using the ATTACH http://www.sqlite.org/lang_attach.html statement. 从SQLite文档中,我可以看到可以使用ATTACH http://www.sqlite.org/lang_attach.html语句链接数据库。 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). 在DbVisualizer中,我创建了两个连接A(A.db)和B(B.db)。 A has a table called TABLE_A and B has a TABLE_B. A有一个名为TABLE_A的表,B有一个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: 我从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. 我试图将A和DB1以及两者的组合都取消单引号,但是似乎没有任何效果。 I have also tried to change A to A.db and that doesn't work. 我也曾尝试将A更改为A.db,但这不起作用。

I don't think the ATTACH command is linking correctly. 我认为ATTACH命令未正确链接。

ATTACH will happily create a new database if the file does not yet exist. 如果该文件尚不存在,ATTACH将愉快地创建一个新数据库。

The file name 'A' specifies a file named "A" in the current directory. 文件名'A'指定当前目录中名为“ A”的文件。

You should specify the full path and the full file name: 您应该指定完整路径和完整文件名:

ATTACH 'C:\some\where\A.db' AS db1;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM