Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE TABLE parent (
- pid INTEGER PRIMARY KEY,
- expired CHAR(1));
- CREATE TABLE child (
- cid INTEGER PRIMARY KEY,
- f_pid INTEGER NOT NULL REFERENCES parent(pid) );
- INSERT INTO parent VALUES (1,'0');
- INSERT INTO parent VALUES (2,'1');
- INSERT INTO parent VALUES (3,'0');
- INSERT INTO child VALUES (1,1);
- INSERT INTO child VALUES (2,1);
- -- this should fail as the parent has expired=1
- INSERT INTO child VALUES (3,2);
- -- this should also fail as it has children referencing it
- UPDATE parent SET expired='1' WHERE pid=1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement