I have table
CREATETABLE nodes (
nameVARCHAR(50) NOTNULL,
parentVARCHAR(50),
PRIMARY KEY (name),
FOREIGN KEY(parent) REFERENCES nodes (name) ONUPDATEcascade
);
I put some data
INSERTINTO nodes (name, parent) VALUES ('n1', NULL);
INSERTINTO nodes (name, parent) VALUES ('n11', 'n1');
INSERTINTO nodes (name, parent) VALUES ('n12', 'n1');
INSERTINTO nodes (name, parent) VALUES ('n13', 'n1');
Let's delete all
DELETEFROM nodes;
Nope, no way.
SQL Error [124] [S1000]: [SQLCODE: <-124>:<FOREIGN KEY constraint failed referential check upon DELETE of row in referenced table>]
[Location: <ServerLoop>]
[%msg: <At least 1 Row exists in table 'SQLUser.nodes' which references key 'NODESPKey2' - Foreign Key Constraint 'NODESFKey3', Field(s) 'parent' failed on referential action of NO ACTION>]