Right you are Clemens: SQLite version 3.23.0 2018-03-16 07:48:43 Enter ".help" for usage hints. Connected to a transient in-memory database. Use ".open FILENAME" to reopen on a persistent database. sqlite> PRAGMA foreign_keys=OFF; sqlite> BEGIN TRANSACTION; sqlite> CREATE TABLE t (id int primary key, value unique); sqlite> CREATE TABLE t1 (id integer primary key, v references t(value)); sqlite> INSERT INTO t1 VALUES(1,1); sqlite> COMMIT; sqlite> pragma foreign_key_check; t1|1|t|0 sqlite> .mode col sqlite> .head on sqlite> pragma foreign_key_check; table rowid parent fkid ---------- ---------- ---------- ---------- t1 1 t 0 sqlite> select * from pragma_foreign_key_check; table rowid parent fkid ---------- ---------- ---------- ---------- t1 1 t 0 sqlite>
--- The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume. >-----Original Message----- >From: sqlite-users [mailto:sqlite-users- >[email protected]] On Behalf Of Clemens Ladisch >Sent: Saturday, 17 March, 2018 13:50 >To: [email protected] >Subject: Re: [sqlite] pragma foreign_key_check > >Mark Wagner wrote: >> The documentation for foreign_key_check says I should be receiving >4 >> columns per violation. I only seem to be getting 1. >> >> CREATE TABLE t (id int primary key, value); >> CREATE TABLE t1 (id integer primary key, v references t(value)); >> sqlite> pragma foreign_key_check; >> Error: foreign key mismatch - "t1" referencing "t" > >The PRAGMA does not even run; you are not getting any result. > >The problem is that there is no valid foreign key constraint; ><http://www.sqlite.org/foreignkeys.html#fk_indexes> says: >| Usually, the parent key of a foreign key constraint is the primary >key >| of the parent table. If they are not the primary key, then the >parent >| key columns must be collectively subject to a UNIQUE constraint or >| have a UNIQUE index. > > >Regards, >Clemens >_______________________________________________ >sqlite-users mailing list >[email protected] >http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list [email protected] http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

