[...]

To my mind the simplified question is:

why returns the "INSERT INTO a" not an error while the "INSERT INTO b" does? How
corresponds this behaviour to the concept of FOREIGN KEYS?

I wrote the code into file.sql (encoding=utf8, if this matters) and started
     sqlite3 -bail test.db3 < file.sql


PRAGMA foreign_keys = ON;

/*
**success INSERT = yes
*/

CREATE TABLE a(
                id                                INTEGER     PRIMARY KEY
AUTOINCREMENT,
                id_staff_editor                   INTEGER     NOT NULL,
                FOREIGN KEY(id_staff_editor)      REFERENCES a(id)
);

INSERT INTO a(id_staff_editor) VALUES(1);

/*
**success INSERT = no
*/

CREATE TABLE b(
                id                                INTEGER     PRIMARY KEY
AUTOINCREMENT,
                id_staff_editor                   INTEGER     NOT NULL,
                FOREIGN KEY(id_staff_editor)      REFERENCES b(id)
);

INSERT INTO b(id_staff_editor) VALUES(2);


Oliver


_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to