mysql-error-1452

MySQL - Cannot add or update a child row: a foreign key constraint fails

北慕城南 提交于 2019-12-01 02:24:58
This seems to be a common error, but for the life of me I can't figure this out. I have a set of InnoDB user tables in MySQL that are tied together via foreign key; the parent user table, and a set of child tables that store email addresses, actions, etc. These are all tied to the parent user table by a foreign key, uid , with all of the parent and child keys being int(10) . All of the child tables have a uid value with a foreign key constraint pointing to user.uid , and set to ON DELETE CASCADE and ON UPDATE CASCADE . When I delete a user from user , all of the child constrained entries are

Foreign key constraint error 1452 in MySQL - Magento import

时光毁灭记忆、已成空白 提交于 2019-11-29 00:09:54
i am trying to import a sql dump of magento along with some product data and i get this foreign key constraint error: `ERROR 1452 (23000) at line 231680: Cannot add or update a child row: a foreign key constraint fails: `magento`.`#sql-b33_27`, CONSTRAINT `FK_CATALOG_COMPARE_ITEM_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID` FOREIGN KEY (`customer_id`) REFERENCES `customer_entity` (`entity_id`) ON DELETE CASCADE ON )` This is the sql code which is causing the error : -- -- Constraints for table `catalog_eav_attribute` -- ALTER TABLE `catalog_eav_attribute` ADD CONSTRAINT `FK_CATALOG_EAV_ATTRIBUTE

MySQL Error Code 1452 Foreign Key Constraint

不羁的心 提交于 2019-11-28 13:51:29
I'm receiving an error when I attempt to create two tables. There was a multivalued dependency, so I separated the tables and came up with this: CREATE TABLE NAME ( NameID Integer NOT NULL AUTO_INCREMENT, Name varChar(255) NOT NULL, CONSTRAINT NAME_PK PRIMARY KEY(NameID) ); CREATE TABLE PHONE ( NameID Integer NOT NULL, PhoneNumber varChar(15) NOT NULL, NumType varChar(5) NOT NULL, CONSTRAINT PHONE_FK FOREIGN KEY(NameID) REFERENCES NAME(NameID), CONSTRAINT PHONE_PK PRIMARY KEY(NameID) ); But when attempting to add values with this code: INSERT INTO NAME (NameID, Name) VALUES (default, 'John Doe

Foreign key constraint error 1452 in MySQL - Magento import

别来无恙 提交于 2019-11-27 15:12:04
问题 i am trying to import a sql dump of magento along with some product data and i get this foreign key constraint error: `ERROR 1452 (23000) at line 231680: Cannot add or update a child row: a foreign key constraint fails: `magento`.`#sql-b33_27`, CONSTRAINT `FK_CATALOG_COMPARE_ITEM_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID` FOREIGN KEY (`customer_id`) REFERENCES `customer_entity` (`entity_id`) ON DELETE CASCADE ON )` This is the sql code which is causing the error : -- -- Constraints for table

ERROR 1452: Cannot add or update a child row: a foreign key constraint fails

跟風遠走 提交于 2019-11-27 07:50:40
问题 I have created two tables in MySQL 5.6.11 as shown below by means of MySQL Workbench 5.2.47. The country table: delimiter $$ CREATE TABLE `country` ( `id` int(11) NOT NULL AUTO_INCREMENT, `country_name` varchar(45) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INC REMENT=2 DEFAULT CHARSET=utf8$$ The state_table : delimiter $$ CREATE TABLE `state_table` ( `id` int(11) NOT NULL AUTO_INCREMENT, `state_name` varchar(45) DEFAULT NULL, `country_id` int(11) DEFAULT NULL, PRIMARY KEY (`id`),

ERROR 1452: Cannot add or update a child row: a foreign key constraint fails

a 夏天 提交于 2019-11-25 23:22:33
问题 I have created tables in MySQL Workbench as shown below : ORDRE table: 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; PRODUKT table: CREATE TABLE Produkt ( ProduktID INT NOT NULL, ProduktBeskrivelse VARCHAR(100) DEFAULT NULL, ProduktFarge VARCHAR(20) DEFAULT NULL, Enhetpris INT DEFAULT NULL, CONSTRAINT Produkt_pk