Home > Database > Mysql Tutorial > body text

Mysqlerror1452-Cannotaddorupdateachildrow:aforeignkeyconstra_MySQL

WBOY
Release: 2016-06-01 13:17:34
Original
1088 people have browsed it

今天在使用load data 将txt文件中的数据导入mysql中的时候,发现了这个错误,产生的原因是外键中的值,在关联的表中并不存在。

load data local infile "E:/javaTest/sql.txt"into table questionFIELDS TERMINATED by ',' (user_id,point,status,title,content,sub_type_id,delete_flg,entry_date_time,reply_date_time);
Copy after login

使用load data 命令的时候,我将逗号作为了分隔符,所以出现了问题,因为有一个字段是String类型的,里面可能会包含逗号,所以分割这块出现了问题。

解决办法也很简单,找到出问题的那个外键,把值修改一下就可以了。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!