简体   繁体   English

MySQL #1452 - 无法添加或更新子行:外键约束失败 ON DELETE CASCADE ON UPDATE CASCADE)

[英]MySQL #1452 - Cannot add or update a child row: a foreign key constraint fails ON DELETE CASCADE ON UPDATE CASCADE)

I have 2 tables about music: songs and images, songs stores the song id, name, year, artist, audio.我有 2 个关于音乐的表:歌曲和图像,歌曲存储歌曲 ID、名称、年份、艺术家、音频。 Artist is an indexed field it is in the images to identify the artist image.艺术家是一个索引字段,它在图像中用于识别艺术家图像。 The problem happens when i want to insert a song in songs.当我想在歌曲中插入歌曲时会出现问题。 appears this error:出现这个错误:


INSERT INTO `songs` (`id`, `name`, `artist`, `year`, `audio`) VALUES ('0', 'x', 'x', '1000', 'x.mp3')
#1452 - Cannot add or update a child row: a foreign key constraint fails (`audio_player`.`songs`, CONSTRAINT `songs_ibfk_1` FOREIGN KEY (`artist`) REFERENCES `images` (`artist`) ON DELETE CASCADE ON UPDATE CASCADE)

both tables are empty.两张桌子都是空的。

any idea?任何想法?

Well, i came too late, but: the error it's because i had to insert into images before of data of artist table好吧,我来得太晚了,但是:错误是因为我必须在艺术家表的数据之前插入图像

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 1452无法添加或更新子行:外键约束失败 - 1452 Cannot add or update a child row: a foreign key constraint fails #1452-无法添加或更新子行:外键约束失败 - #1452 - Cannot add or update a child row: a foreign key constraint fails #1452-无法添加或更新子行:外键约束失败 - #1452 - Cannot add or update a child row: a foreign key constraint fails #1452 - 无法添加或更新子行:外键约束失败 - #1452 - Cannot add or update a child row: a foreign key constraint fails #1452-无法添加或更新子行:外键约束失败3 - #1452 - Cannot add or update a child row: a foreign key constraint fails 3 1452 - 无法添加或更新子行:外键约束失败 - 1452 - Cannot add or update a child row: a foreign key constraint fails LARAVEL:MYSQL:违反完整性约束:1452无法添加或更新子行:外键约束失败 - LARAVEL:MYSQL : Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails 休眠级联保存错误(无法添加或更新子行:外键约束失败) - Hibernate cascade saving error (Cannot add or update a child row: a foreign key constraint fails) MySQL Workbench:错误代码1452。无法添加或更新子行:外键约束失败 - MySQL Workbench: Error Code 1452. Cannot add or update a child row: a foreign key constraint fails Mysql:错误代码:1452。无法添加或更新子行:外键约束失败 - Mysql: Error Code: 1452. Cannot add or update a child row: a foreign key constraint fails
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM