mysql无法添加或更新子行_MySQL无法添加或更新子行

我有两个表:tblACTypeCharacteristics和tblAircrafts。

tblACType特征定义:

create table if not exists tblACTypeCharacteristics(

idAC_type varchar(255) not null,

numPassengers int,

primary key(idAC_type));tblAircrafts的定义:

create table if not exists tblAircrafts(

idAC int not null auto_increment,

txtAC_tag varchar(255) not null,

txtAC_type varchar(255) not null,

primary key(idAC, txtAC_tag));另外,我添加了如下所示的外键:

alter table tblaircrafts add foreign key(txtAC_type)

references tblactypecharacteristics(idAC_type);在特定类型的特性中,为每种类型的飞机定义最大乘客数量。

在tblAircraft都列出了所有飞机。

我可以输入一个新的飞机,例如:

insert into tblaircrafts (txtAC_tag, txtAC_type) values ('OE-LDA','A319-112');但是由于周围有很多飞机,我不想手动添加每一架飞机。

我想通过csv文件导入它们(我有一些飞机的列表)。

我将它导入为:

load data local infile 'C:\\Users\\t_lichtenberger\\Desktop\\tblAircrafts.csv'

into table tblaircrafts

character set utf8

fields terminated by ';'

lines terminated by '\n'

ignore 1 lines;但是,因为我想将.csv文件导入到tblaircraft表中,所以出现以下错误:

15:08:37 alter table tblaircrafts add foreign key(txtAC_type) references tblactypecharacteristics(idAC_type) Error Code: 1452. Cannot add or update a child row: a foreign key constraint fails (`pilotproject`.`#sql-11d0_2da`, CONSTRAINT `#sql-11d0_2da_ibfk_1` FOREIGN KEY (`txtAC_type`) REFERENCES `tblactypecharacteristics` (`idAC_type`)) 0.641 sec我无法解释为什么。列数是相同的,列的数据类型是相同的。而且我已经对tblACTypeCharacteristic表中没有的AC_types进行了双重检查,它应该很好。

csv文件的前几行看起来如下所示:

mboAN.png

任何建议为什么错误仍然存​​在?

提前感谢你!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值