免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
MySQL Foreign Key Error 1005 errno 150
30accepted
When creating a foreign key constraint, MySQL requires a usable index on both the referencing table and also on the referenced table. The index on the referencing table is created automatically if one doesn't exist, but the one on the referenced table needs to be created manually (Source). Yours appears to be missing.
Test case:
CREATE TABLE tbl_a ( id int PRIMARY KEY, some_other_id int, value int) ENGINE=INNODB;Query OK, 0 rows affected (0.10 sec)CREATE TABLE tbl_b ( id int PRIMARY KEY, a_id int, FOREIGN KEY (a_id) REFERENCES tbl_a (some_other_id)) ENGINE=INNODB;ERROR 1005 (HY000): Can't create table 'e.tbl_b' (errno: 150)But if we add an index on some_other_id:
CREATE INDEX ix_some_id ON tbl_a (some_other_id);Query OK, 0 rows affected (0.11 sec)Records: 0 Duplicates: 0 Warnings: 0CREATE TABLE tbl_b ( id int PRIMARY KEY, a_id int, FOREIGN KEY (a_id) REFERENCES tbl_a (some_other_id)) ENGINE=INNODB;Query OK, 0 rows affected (0.06 sec)This is often not an issue in most situations, since the referenced field is often the primary key of the referenced table, and the primary key is indexed automatically.
本站僅提供存儲服務,所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Mysql 的ERROR 1005 (HY000): Can't create table 'xxx' (errno: 150)
揭示十年數(shù)據(jù)庫經(jīng)驗,告訴你如何輕松應對常見問題(SQL 小虛竹)
如何收縮Mysql的ibdata1文件
mysql基礎知識摘要
[MS SQL] Cannot truncate table,because it is being referenced by a FOREIGN KEY constraint?
Access、MSSQL、MYSQL數(shù)據(jù)庫之間有什么區(qū)別
更多類似文章 >>
生活服務
分享 收藏 導長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服