外键约束 [英] foreign key constraint
本文介绍了外键约束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们可以在一个表中有一个或多个外键.
can we have one or more foreign key in one table.
推荐答案
是的!但是每个外键约束都将进入其自己的字段.联接表是表的一个很好的例子,在大多数情况下,表仅具有外键.这是在关系数据库中创建的多对多关系.
祝你好运!
Yes you can! But each foreign key constraint would go in its own field. A join-table is a good example of a table that, in most cases, only has foreign keys. This is how many-to-many relations are created (in relational database ).
Good luck!
是的.
请参见以下示例:
http://www.w3schools.com/sql/sql_foreignkey.asp [
yes.
see the following for examples:
http://www.w3schools.com/sql/sql_foreignkey.asp[^]
create table A
(
id int constraint PK_D primary key,
idb int constraint FK_D_IDB foreign key references B(id),
idc int constraint FK_D_IDC foreign key references C(id),
);
这篇关于外键约束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文