在另一个模式中对表的外键引用 [英] Foreign key reference to table in another schema

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

问题描述

我试图在一个表上创建外键,并引用了不同模式中表的一列.

I tried to create a foreign key on one of my tables, referencing a column of a table in a different schema.

类似的东西:

ALTER TABLE my_schema.my_table ADD (
  CONSTRAINT my_fk
    FOREIGN KEY (my_id)
    REFERENCES other_schema.other_table(other_id)
)

由于我获得了必要的赠款,所以效果很好.

Since I had the necessary grants, this worked fine.

现在,我想知道是否有原因不引用其他模式中的表,或者有什么需要注意的地方?

Now I wonder if there are reasons for not referencing tables in a different schema, or anything to be careful about?

推荐答案

这样做没问题.在表之间建立外键关系时,架构实际上没有任何影响.只需确保适当的人员具有您打算使用的架构所必需的权限即可.

No problem doing this. Schemas really have no impact when establishing foreign key relationships between tables. Just make sure the appropriate people have the permissions necessary for the schemas you intend to use.

这篇关于在另一个模式中对表的外键引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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