SQLite Foreign Key

前端 未结 5 1483
刺人心
刺人心 2020-12-24 01:15

I\'m following the instructions from the SQLite documentation at http://www.sqlite.org/foreignkeys.html however my attempt to add a foreign key is failing. Here are my crea

5条回答
  •  粉色の甜心
    2020-12-24 01:47

    Simply you are missing checklist_id column in your item table. You need to declare it before you want to set it as FOREIGN KEY. You tried to create FK on non-existing column and this is reason why it doesn't work.

    So you need to add this:

    checklist_id INTEGER,
    FOREIGN KEY(checklist_id) REFERENCES checklist(_id)
    

    now it should works.

提交回复
热议问题