日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

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

發布時間:2025/3/15 数据库 17 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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无法添加或更新子行的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。