James K. Lowden wrote:
> I seem to be getting a foreign key check anomaly.  I've checked the
> constraint mentioned in the error message (and the other one, just in
> case).  Am I overlooking something, or has this been fixed since 3.8.4.1?
>
> sqlite> pragma foreign_key_check;
> Error: foreign key mismatch - "Field" referencing "Segm"

There are two error messages related to foreign key constraints.

You get "FOREIGN KEY constraint failed" if there is invalid data,

You get "foreign key mismatch" if you do not have the required indexes,
i.e., according to a comment in the source,
1) The named parent key columns do not exist, or
2) The named parent key columns do exist, but are not subject to a
   UNIQUE or PRIMARY KEY constraint, or
3) No parent key columns were provided explicitly as part of the
   foreign key definition, and the parent table does not have a
   PRIMARY KEY, or
4) No parent key columns were provided explicitly as part of the
   foreign key definition, and the PRIMARY KEY of the parent table
   consists of a different number of columns to the child key in
   the child table.

Also see <http://sqlite.org/foreignkeys.html#fk_indexes>.


Regards,
Clemens

Reply via email to