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

歡迎訪問 生活随笔!

生活随笔

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

数据库

mysql 1005_MYSQL使用错误 MYSQL中ERROR 1005

發(fā)布時間:2023/12/19 数据库 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql 1005_MYSQL使用错误 MYSQL中ERROR 1005 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

在使用MYsql的時候,在操作不當時,很容易出現(xiàn) ERROR 1005 (HY000): Can't create table 這類錯誤。很多站長朋友可能需要排查很久才會找到問題的原因其實很簡單,希望這篇文章可以對站長朋友以及Mysql初學者一點幫助。

MYSQL官方提供的問題原因:

在信息中有一組【LATEST FOREIGN KEY ERROR】會有最近錯誤的詳細描述和解決辦法。

Cannot find an index in the referenced table where the referenced columns appear as the first columns, or column types in the table and the referenced table do not match for constraint.

(譯:不能在“被reference的表”里找到包含“被reference字段”的索引,或者是兩個關聯(lián)字段類型不匹配)

以下介紹兩個示例:

示例一:

create table booktype

(

btid?? int(5) unsigned zerofill auto_increment not null primary key,

btname varchar(100) not null unique,

btnote text

);

create table books

(

bid int(5) unsigned zerofill auto_increment not null primary key,

bname char(30) not null,

isbn char(50) not null,

author char(30) not null,

press?? text,

summary text,

bcount int not null default 0,

btid?? int,

foreign key(btid) references booktype(btid)

);

出現(xiàn)的報錯:

ERROR 1005 (HY000): Can't create table '.\bookdata\books.frm' (errno: 150)

主要問題以及解決辦法是:

foreign key(btid) references booktype(btid) 中books表的 btid?? 是int和booktype表中的btid設置的關聯(lián)字段類型不匹配,books表中btid改正成:btid?? int(5) unsigned zerofill ,就不會報錯了,創(chuàng)建表和修改表地時候常常一步小小就忘記了這個.

總結

以上是生活随笔為你收集整理的mysql 1005_MYSQL使用错误 MYSQL中ERROR 1005的全部內容,希望文章能夠幫你解決所遇到的問題。

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