Error 1452 Mysql Ayuda Urgente Por Favor
Contents |
de inicio Todas las categorÃas Arte y humanidades Autos y transporte Belleza y moda Ciencias sociales Ciencias y matemáticas Comer y beber Computadoras e internet Deportes Educación y formación Electrónica cannot add or update a child row a foreign key constraint fails mysql de consumo Embarazo y maternidad Familia, Amor y relaciones Hogar cannot add or update a child row a foreign key constraint fails on delete cascade on update cascade) y jardinerÃa Juegos y recreación Mascotas Medio ambiente Música y entretenimiento Negocios locales Negocios
Error Code: 1452
y finanzas Noticias y eventos PolÃtica y gobierno Restaurantes Salud y belleza Sociedad y cultura Viajes Yahoo y sus Productos Internacional Argentina Australia Brasil
#1452
Canadá Francia Alemania India Indonesia Italia Malasia Nueva Zelanda Filipinas Quebec Singapur Taiwán Hong Kong España Tailandia Reino Unido e Irlanda Estados Unidos Vietnam Español Acerca de Acerca de respuestas Normas de la comunidad Clasificación Colaboradores oficiales Puntos y niveles Blog Consejos de seguridad Computadoras e internet Programación y set foreign_key_checks = 0; Diseño Siguiente ¿Cómo corregir el error 1452: cannot add or update a child row: a foreign key constraint fails en mysql workbench? me aparace este error cuando intento agregar datos a la tabla mediante la consola de mysql. Actualizar: por favor ayudenme Seguir 1 respuesta 1 Notificar abuso ¿Estás seguro que deseas eliminar esta respuesta? Sà No Lo sentimos, ocurrió un error. Trending Now Respuestas Saludos, este error se presenta cuando dicha tabla está relacionada con otra; es decir, que tienes una llave foránea en la misma, entonces al tratar de almacenar datos en tu tabla, deberás asignar un valor en el campo que hace las veces de llave foránea y dicho valor debe existir en la llave principal de la tabla con la cual estas relacionando la tabla actual, este tema de relacionar tablas lo puedes ampliar en este post: http://goo.gl/enG5J8 Fuente(s):
Datos General » Mysql » Mysql error 1452 : Cannot add or update a child row: a foreign key constraint fails Estas en el tema de Mysql error 1452 : Cannot add or update a
Constraint Mysql
child row: a foreign key constraint fails en el foro de Mysql en Foros del cannot add foreign key constraint Web. Buenas tengo lo siguente TABLA1 Indices : codigo , proveedor codigo : varchar(15) proveedor : int(4) TABLA2 Indices : codigo , foreign key mysql proveedor codigo : varchar(15) ... #1 (permalink) 23/04/2010, 09:54 radge Fecha de Ingreso: enero-2004 Ubicación: here I Am Mensajes: 413 Antigüedad: 12 años, 8 mesesPuntos: 1 Mysql error 1452 : Cannot add or update a https://mx.answers.yahoo.com/question/index?qid=20140807214224AAD322k child row: a foreign key constraint fails Buenas tengo lo siguente TABLA1 Indices : codigo , proveedor codigo : varchar(15) proveedor : int(4) TABLA2 Indices : codigo , proveedor codigo : varchar(15) proveedor : int(4) Y intento poner una clave foranea con este comando Código: ALTER TABLE tabla1 ADD CONSTRAINT `FK_tabla1` FOREIGN KEY `FK_tabla1` (`codigo`, `proveedor`) REFERENCES `tabla2` (`codigo`, `proveedor`) ON DELETE NO ACTION ON UPDATE NO ACTION; Y todo el rato recibo el error Código: http://www.forosdelweb.com/f86/mysql-error-1452-cannot-add-update-child-row-foreign-key-constraint-fails-800293/ Cannot add or update a child row: a foreign key constraint fails (`XXXXXXXXX/#sql-810_70491`, CONSTRAINT `fk_tabla1` FOREIGN KEY (`codigo`, `proveedor`) REFERENCES `tabla2`(`codigo`, `proveedor`) ON DELETE NO ACTION ON UPDATE No se que hacer... Gracias radge __________________ dime la ip http://www.dimelaip.es #2 (permalink) 23/04/2010, 10:33 jurena Colaborador Fecha de Ingreso: marzo-2008 Ubicación: Cáceres Mensajes: 3.735 Antigüedad: 8 años, 6 mesesPuntos: 300 Respuesta: Mysql error 1452 : Cannot add or update a child row: a foreign key constra Mira a ver si es que tienes en la tabla1 algún registro con codigo y proveedor (ambos) que no existan en tabla2 en un mismo registro. Eso supondría un problema cuando exiges integridad. Mira a ver Una consulta como esta podría ayudarte a descubrirlo SELECT * FROM tabla1 t2 LEFT JOIN tabla2 t1 ON (t2.codigo = t1.codigo AND t2.proveedor = t1.proveedor) WHERE t1.proveedor IS NULL No lo he probado. Etiquetas: child, constraint, key, row, update, foreignkey ¿Tienes una mejor respuesta a este tema? ¿Quiéres hacerle una pregunta a nuestra comunidad y sus expertos? Registrate Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual. « Tema Anterior | Próximo Tema » La zona horaria es GMT -6. Ahora son las 05:31. Contáctenos - Archivo - Política de Privacidad - Pol
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings http://stackoverflow.com/questions/21659691/error-1452-cannot-add-or-update-a-child-row-a-foreign-key-constraint-fails and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it foreign key only takes a minute: Sign up ERROR 1452: Cannot add or update a child row: a foreign key constraint fails up vote 30 down vote favorite 6 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 foreign key 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 primary key(ProduktID) ) engine = InnoDB; and ORDRELINJE table: Create table Ordrelinje( Ordre int NOT NULL, Produkt int NOT NULL, AntallBestilt int DEFAULT NULL, constraint Ordrelinje_pk primary key(Ordre, Produkt), constraint Ordrelinje_fk foreign key(Ordre) references Ordre(OrdreID), constraint Ordrelinje_fk1 foreign key(Produkt) references Produkt(ProduktID) ) engine = InnoDB; so when I try to insert values into ORDRELINJE table i get : Error Code: 1452. Cannot add or update a child row: a foreign key constraint fails (srdjank.Ordrelinje, CONSTRAINT Ordrelinje_fk FOREIGN KEY (Ordre) REFERENCES Ordre (OrdreID)) I've seen the other posts on this topic, but no luck. Am I overseeing something or ... Any idea what to do? mysql mysql-error-1452 share|improve this question edited Feb 9 '14 at 14:34 Mihai 15.3k52442 asked Feb 9 '14 at 13:37 user3289677 151123 1 possible duplicate of Mysql error 1452 - Cannot add or update a child row: a foreign key constraint fails &