好吧,我对递归表有另一个问题。
这是表格定义:
create table seguridad (
cod_emple int(6) ZEROFILL NOT NULL,
cod_jefe int(6) ZEROFILL DEFAULT NULL,
TIP int(5) NOT NULL,
division_seguridad varchar(40) NOT NULL,
PRIMARY KEY (cod_emple),
INDEX (cod_jefe),
FOREIGN KEY (cod_jefe) REFERENCES seguridad (cod_emple) ON DELETE RESTRICT ON UPDATE CASCADE,
FOREIGN KEY (cod_emple) REFERENCES empleados (cod_emple) ON DELETE RESTRICT ON UPDATE CASCADE
) ENGINE=INNODB;
但是当我尝试插入时:
insert into seguridad values (002237, 2213, 28465, 'VIGILANTE');
或
insert into empleados values (002889, NULL, 26675, 'GUARDIA CIVIL');
我在第一次出现此错误:
#1452. Cannot add or update a child row: a foreign key constraint fails (`prision_arenales`.`seguridad`, CONSTRAINT `seguridad_ibfk_1` FOREIGN KEY (`cod_jefe`) REFERENCES `seguridad` (`cod_emple`) ON UPDATE CASCADE)
这是第二个:
#1136. Column count doesn't match value count at row 1
做了同样的事情
答案 0 :(得分:1)
第一个意味着{{1}}不包含值{{1}}
第二个意味着{{1}}没有5列