Oracle:SQL語句--對錶的操作——添加外鍵約束

——添加外鍵約束

語法:
alter table 表1-表名
add constraint 外鍵名稱(一般外鍵名稱爲”fK_”開頭) foreign key (要設爲外鍵的列名)
references 表2-表名(與哪個表有關聯) (表2中該列列名);

alter table T_Result
add constraint fk_studentId2 foreign key (studentId)
references T_Student (studentId);

alter table t_CardInfo
add constraint fk_customerID foreign key(customerid)
references T_UserInfo (customerid);

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章