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文件的前幾行看起來如下所示:
任何建議為什么錯誤仍然存??在?
提前感謝你!
總結
以上是生活随笔為你收集整理的mysql无法添加或更新子行_MySQL无法添加或更新子行的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 记忆性递归:1
- 下一篇: php 怎么使循环少一次,PHP-如何让