Details
-
Bug
-
Status: Closed (View Workflow)
-
Minor
-
Resolution: Not a Bug
-
10.3.29, 10.5.10
-
Ubuntu20.04: 10.3.29
Docker:10.5.10
Description
create table Dep( |
id INT UNSIGNED AUTO_INCREMENT primary key, |
dep varchar(255) not null unique, |
dep_sjm varchar(255), |
p_dep INT UNSIGNED default NULL |
);
|
ALTER TABLE Dep |
ADD FOREIGN KEY (p_dep) |
REFERENCES Dep (id) |
ON UPDATE CASCADE; |
|
insert into Dep(id,dep,dep_sjm) values (209604,"sales department","XSB"); |
|
insert into Dep(id, dep, dep_sjm, p_dep) values (203634,"sales department 1","XSB",209604); |
update Dep set id=48615 where id=209604; |
output: ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails (`test`.`Dep`, CONSTRAINT `Dep_ibfk_1` FOREIGN KEY (`p_dep`) REFERENCES `Dep` (`id`) ON UPDATE CASCADE)
|