我在mysql中有以下代碼。MySQL:如何添加外鍵
create table employee(
e_id int(10) not null auto_increment,
user_id int(10),
usertype_id default 1,
name varchar(50),
primary key (e_id)
);
create table relation(
r_id int(10) not null auto_increment,
user_id int(10) not null,
usertype_id int(10) not null,
interest_id int(10) not null,
primary key (id)
);
首先,我想user_id
將具有相同的值作爲e_id
柱;
然後,我想補充user_id
和usertype_id
如表relation
如表employee
外鍵user_id
和usertype_id
的統一。
你知道該怎麼做嗎?
非常感謝。
您還應該級聯更新 – arthurprs 2010-02-23 17:51:56
@thanks vanessa,實際上,我想爲user_id和usertype_id添加一個外鍵作爲一個整體。那可能嗎? – 2010-02-23 19:31:32