我剛開始在大學學習MYSQL,我有一個重要的任務是爲我的課程做。我必須創建一個小型數據庫,因爲errno(150) 我似乎無法添加帶有外鍵的表。MYSQL外鍵Errno(150)無法創建表
create table Country
(CountryName varchar (50) not null,
Primary Key (CountryName));
create table InterestGroup
(IntrestgrpName varchar (30) not null,
Primary Key (IntrestgrpName));
create table Organisation
(OrgName varchar (50) not null,
OrgAddress varchar (30),
OrgTelNo.varchar (30),
Primary Key (OrgName));
create table Qualification
(QualName varchar (50) not null,
Primary Key (QualName));
create table Member
(MemberID varchar (15) not null,
MemberName varchar (30),
MemberAdd varchar (50) not null,
CountryName varchar (50) not null,
IntrestgrpName varchar (30) not null,
QualName varchar (50) not null,
OrgName varchar (50) not null,
Primary Key (MemberID),
Foreign Key (CountryName) References Country (CountryName),
Foreign Key (IntrestgrpName) References InterestGroup (InterestgrpName),
Foreign Key (QualName) References Qualification (Qualname),
Foreign Key (OrgName) References Organisation (OrgName));
我不能似乎得到將要創建的成員表,它給這個錯誤, ERROR 1005(HY000):無法創建表 'iicp.member'(錯誤:150) 在此先感謝對於幫助,我真的需要解決這個問題
您是否使用InnoDB或MyISAM作爲引擎類型?我認爲只有InnoDB支持外鍵。如果您不擁有服務器本身,則可能需要向DBA詢問這些信息。 – Lukos 2013-02-11 14:03:25
你確定你想要MemberID varchar數據類型嗎? – 2013-02-11 14:07:48