load data local infile '/tmp/my_data.tsv'
into table my_schema.my_table
fields terminated by '\t'
optionally enclosed by '"'
escaped by '\\'
lines terminated by '\n';
mysql -u username -p --local-infile --execute= \
"load data local infile '/tmp/my_data.tsv' into table my_schema.my_table \
fields terminated by '\t' optionally enclosed by '\"' escaped by '\\\\';"
显示错误消息:
Cannot add or update a child row: a foreign key constraint fails
(`my_schema`.`my_table`, CONSTRAINT `other_table` FOREIGN KEY
(`id`) REFERENCES `other_table` (`id`))
1条答案
按热度按时间w8biq8rn1#
由于某种原因,当您正在加载的数据违反了外键约束(在here中有更详细的描述)时,MySQL会给出这个模糊的错误消息。
我设法通过直接从命令行执行
load data
命令来获得正确的错误消息。* 即 * 运行:显示错误消息:
删除违反外键约束的行后,我可以导入数据。