I have a table under SQLite as follows:
CREATE TABLE "node" (
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`namespace` TEXT NOT NULL,
`name` TEXT,
`parent_id` INTEGER DEFAULT NULL,
`str_value` TEXT DEFAULT NULL,
`int_value` INTEGER DEFAULT NULL,
FOREIGN KEY(parent_id) REFERENCES node(id) ON DELETE CASCADE
);
INSERT INTO `node` VALUES ('1','xxx','Parameter',NULL,NULL,NULL);
INSERT INTO `node` VALUES ('2','xxx','Info','1',NULL,NULL);
INSERT INTO `node` VALUES ('3','xxx','Daten','1',NULL,NULL);
INSERT INTO `node` VALUES ('4','xxx','Kennung','2',NULL,'100');
INSERT INTO `node` VALUES ('5','xxx','Version','2',NULL,'1');
INSERT INTO `node` VALUES ('6','xxx','Typ','2','AMIS',NULL);
INSERT INTO `node` VALUES ('7','xxx','Revision','2',NULL,'1');
When I execute
delete from node where id=2;
I expect nodes with id=4,5,6,7 also to be deleted, because of DELETE CASCADE. However, this is not the case - only id=2 is deleted. Why?
Many Thanks, Michael
Aucun commentaire:
Enregistrer un commentaire