oracle中的外键 [英] foreign keys in oracle

查看:138
本文介绍了oracle中的外键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在MSSQL和MySQL中声明外键时我们使用了这种格式



CONSTRAINT fk_emp FOREIGN KEY(P_Id)

参考人数(P_Id )



但在oracle中没有指定我们需要添加引用的表的列名。



它是这样完成的



CONSTRAINT fk_emp外键(P_Id)

参考人物



在这种情况下,db如何知道哪个列需要用person表中的列引用?

In MSSQL and MySQL when declaring foreign keys we used this format

CONSTRAINT fk_emp FOREIGN KEY (P_Id)
REFERENCES Persons(P_Id)

but in oracle don't specify the column name of the table that we need to add a reference to.

it was done like this

CONSTRAINT fk_emp FOREIGN KEY (P_Id)
REFERENCES Persons

in this case how does the db know which column needs to be referenced with the column in persons table?

推荐答案

根据文档 - http://docs.oracle.com/cd/B28359_01/server.111/ b28286 / clauses002.htm [ ^ ],因为引用的键是父表的主键,所引用的键列n艾姆斯是可选的。。

Scott
According to the documentation - http://docs.oracle.com/cd/B28359_01/server.111/b28286/clauses002.htm[^], " Because the referenced key is the primary key of the parent table, the referenced key column names are optional.".
Scott


这篇关于oracle中的外键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆