天天看點

mysql 建立外鍵出現的問題

mysql 寤哄??????跺????50??璇?

Mysql??璇?锛?error Code: 1005. Can't create table 'joblog.sc' (errno: 150)

create table sc

(

id int(10) unsigned not null auto_increment comment 'id',

Sno int(10) unsigned not null default '0' comment '瀛???,

Cno int(10) unsigned not null default '0' comment '璇劇???,

Grade int(10) unsigned default null comment '??缁?,

primary key (id),

constraint FK_sc_1 foreign key (Sno) references student(id) ,

constraint FK_sc_2 foreign key(Cno) references course(id)

)engine=InnoDB default charset=gb2312;

??????message_demo琛ㄧ??type锛?澶???锛?灞??у??message_type琛ㄧ??id锛?涓婚??锛?瀹?涔?涓???锛??變??????ㄥ緩绔?琛ㄤ?????寤虹????澶????崇郴锛?涔???缁?type瀛?娈靛??浜?涓?unsigned锛???id瀛?娈靛??娌″??锛???姝ゆ?ラ????

??FOREIGN KEY绾?????

澶???瀹?涔???浠?涓??????碉?

路 ????tables蹇?椤繪??InnoDB??锛?瀹?浠?涓??芥??涓存?惰〃??

路 ?ㄥ??ㄨ〃涓?锛?蹇?椤繪??涓?涓?绱㈠?锛?澶?????浠ュ???風??椤哄?琚????ㄥ?朵腑浣?涓虹??涓?????杩??蜂?涓?绱㈠?濡???涓?瀛????瀹?蹇?椤誨?ㄥ??ㄨ〃??琚????ㄥ??寤恒??

路 ?ㄥ??ㄨ〃涓?锛?蹇?椤繪??涓?涓?绱㈠?锛?琚?寮??ㄧ????浠ュ???風??椤哄?琚????ㄥ?朵腑浣?涓虹??涓?????

路 涓?????瀵瑰???????绱㈠???缂???杩??風??????涔?涓???BLOB??TEXT??涓?琚??????ㄤ?涓?澶???涓?锛?杩?????涓哄?矽?浜?????绱㈠?蹇?椤繪?繪??????涓?涓???缂??垮害??

路 濡???CONSTRAINTsymbol琚?缁??猴?瀹??ㄦ?版??搴???蹇?椤繪????涓?????濡???瀹?娌℃??琚?缁??猴?InnoDB???ㄥ??寤鴻?涓???瀛???

. 澶???

澶???澧?寮轟負?版??搴?寮???浜哄????渚?浜?澶?椤圭??澶?锛?

路 ??瀹??寵??璁捐?℃?闆?锛?澶???绾???浣垮?绋?搴????撮?懼?涓?涓??存?у??ユ?版??搴???

路 ?版??搴????″?ㄥ?鋒????涓?寮?绾???妫??ュ???斤?????娌℃??蹇?瑕??ㄥ??ㄧ?搴?涓?渚ф?ц?杩?绫繪??ャ??杩??鳳?灏辨??や?涓???搴??ㄧ?搴?浣跨?ㄤ????瑰?妫??ョ害???????芥?с??

路 浣跨?ㄧ駭???存?闆?????わ?绠???浜?搴??ㄧ?搴?浠g????

路 璁捐?℃?闆???澶??????╀?浠ユ??妗f?瑰?璁闆?琛ㄩ?寸???崇郴??

璇瘋?頒?锛?杩?浜?濂藉???浠ユ?版??搴????″?ㄤ負?ц?蹇?瑕?妫??ヨ??????棰?澶?寮???涓轟唬浠風???????″?ㄩ?澶?妫??ヤ?褰卞???ц?斤?瀵逛???浜?搴??ㄧ?搴?锛?璇ョ?規?т???娆㈣?锛?搴?灏介???垮????锛??轟?璇ュ????锛??ㄤ?浜?涓昏?????涓?搴??ㄧ?搴?涓?锛??ㄥ??ㄧ?搴?绾у??涓?瀹??戒?澶????昏?锛???