SQLite version 3.7.9 2011-11-01 00:52:41
sqlite> PRAGMA foreign_keys = 1;
sqlite> CREATE TABLE foo(name);
sqlite> CREATE TABLE bar(foo_rowid REFERENCES foo(rowid));
sqlite> INSERT INTO foo VALUES('baz');
sqlite> SELECT rowid, name FROM foo;
1|baz
sqlite> INSERT INTO bar (foo_rowid) VALUES (1);
Error: foreign key mismatch
Why does this error occur? It is a DML error, but I don't know what's wrong because:
fooexists.foo.rowidexists.foo.rowidis the primary key offooand therefore constrained to uniqueness.bar.foo_rowidis one column, which matches the fact thatfoo.rowidis one column.