Questions tagged «mysql-error-1452»

21
MySQL错误1452-无法添加或更新子行:外键约束失败
我有一个奇怪的问题。我正在尝试向一个引用另一个表的表添加外键,但是由于某种原因它失败了。以我对MySQL的有限了解,唯一可能令人怀疑的是,另一张表上有一个外键引用了我要引用的表。 我已经SHOW CREATE TABLE对两个表进行了查询,sourcecodes_tags是带有外键的表,sourcecodes还是被引用的表。 CREATE TABLE `sourcecodes` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `user_id` int(11) unsigned NOT NULL, `language_id` int(11) unsigned NOT NULL, `category_id` int(11) unsigned NOT NULL, `title` varchar(40) CHARACTER SET utf8 NOT NULL, `description` text CHARACTER SET utf8 NOT NULL, `views` int(11) unsigned NOT NULL, `downloads` int(11) …

18
错误1452:无法添加或更新子行:外键约束失败
我已经在MySQL Workbench中创建了表,如下所示: ORDRE表: CREATE TABLE Ordre ( OrdreID INT NOT NULL, OrdreDato DATE DEFAULT NULL, KundeID INT DEFAULT NULL, CONSTRAINT Ordre_pk PRIMARY KEY (OrdreID), CONSTRAINT Ordre_fk FOREIGN KEY (KundeID) REFERENCES Kunde (KundeID) ) ENGINE = InnoDB; 产品表: CREATE TABLE Produkt ( ProduktID INT NOT NULL, ProduktBeskrivelse VARCHAR(100) DEFAULT NULL, ProduktFarge …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.