Is there any way in SQLite3 to have a foreign key in the main database that references the columns in the attached database (or vice versa?)
I hope to share an accessible database (read-only) between several processes, each of which has its own main database (read / write).
I create the parent table as follows (in the database "ParentDB"):
create table Parent (id integer primary key);
Now I try this in the main database:
attach 'parent.sqlite3' as ParentDB;
create table Child (id integer not null references Parent (id),
constraint PK_Child primary key (id));
insert into ParentDB.Parent (id) values (42);
When I try, it creates a foreign key without errors. Now I am trying to insert a row into a child table:
insert into Child (id) values (42);
And I get this error:
Error: no such table: main.Parent
So it seems that it is always assumed that the parent and child tables belong to the same database.
, .
?
, , , .