Ok, as the ATTACH is not committed into the database, I understand why we cannot have cross-database constraints.
Thanks! Sylvain -----Original Message----- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Pavel Ivanov Sent: Wednesday, January 20, 2010 6:14 PM To: General Discussion of SQLite Database Subject: Re: [sqlite] Attached database > Is it possible? If I attach database B to database A and database A to > database B. As these statements are committed into A and B, they stay > attached even if I close and reopen. So If another process opens A (or > B), it has B (or A) attached to A (or B). I don't have to repeat the > ATTACH statement each time I open the database right? No, that's incorrect. ATTACH commands are per-connection and never get committed to database. You have to attach databases any time you want to use them. You can attach them in any order or do not attach them at all - doesn't make any difference for SQLite, it's just for your convenience and it can make difference in how you write your queries. Pavel On Wed, Jan 20, 2010 at 12:07 PM, Tiberio, Sylvain <sylvain.tibe...@eads.com> wrote: > Hi, > >> And how precisely do you expect SQLite to pull that off? > Ignore the DETACH command and set and error... No? As when you insert > a row that doesn't respect a constraints. > >> How it is going to stop you from, say, opening a separate connection >> to one of these databases (and never attaching the other), possibly >> from a different process? > Is it possible? If I attach database B to database A and database A to > database B. As these statements are committed into A and B, they stay > attached even if I close and reopen. So If another process opens A (or > B), it has B (or A) attached to A (or B). I don't have to repeat the > ATTACH statement each time I open the database right? > > > I agree that if data are split in several files, it is a way to > introduce constraints violation (for instance if I backup/restore one > file and not the others...). > > My first need was to separate my database into two separate files. In > the 1st file I store my main data, In the second I store relation > between data (and I accept to lost it). I would like to be able to > backup/restore only the 1st file. It works fine with ATTACH but I > don't have constraints on reference and view! > > Sylvain > > -----Original Message----- > From: sqlite-users-boun...@sqlite.org > [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Igor Tandetnik > Sent: Wednesday, January 20, 2010 5:17 PM > To: sqlite-users@sqlite.org > Subject: Re: [sqlite] Attached database > > Tiberio, Sylvain <sylvain.tibe...@eads.com> wrote: >> About "cross-database foreign key constraints": I agree with you that >> attached database can be dettached or changed. So as it is not >> possible to create the foreign key constraint with no attached >> database (because parent table doesn't exist), I can imagine that >> SQLite doesn't allow to detach database when foreign key constraints >> exist on it. > > And how precisely do you expect SQLite to pull that off? How it is > going to stop you from, say, opening a separate connection to one of > these databases (and never attaching the other), possibly from a different process? > > Igor Tandetnik > > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users