在与Oracle交替模式外键?(Foreign keys in alternate schemas

2019-06-27 14:31发布

我有两个模式,我们姑且称之为BOB和FRED。 我需要从架构BOB调用表架构FRED使用的主键在该表的外键。 我已经设置了模式FRED适当的补助,让BOB访问它,但每当我运行该脚本,它抱怨说我没有正确的权限。 是否有我需要的地方更改其他设置? 可即使这样做?

我的FK创建如下:

ALTER TABLE "BOB"."ITEMGROUP" WITH CHECK ADD CONSTRAINT FK_ITEMS_ITEM FOREIGN KEY (ItemID)
REFERENCES "FRED"."ITEMS"(ItemID)

而我做的是授与:

GRANT ALTER ON "FRED"."ITEMS" TO "BOB"

我收到此错误信息:

SQL Error: ORA-01031: insufficient privileges 
01031. 00000 -  "insufficient privileges"

*Cause:    An attempt was made to change the current username or password
           without the appropriate privilege. This error also occurs if
           attempting to install a database without the necessary operating
           system privileges.
           When Trusted Oracle is configure in DBMS MAC, this error may occur
           if the user was granted the necessary privilege at a higher label
           than the current login.

*Action:   Ask the database administrator to perform the operation or grant
           the required privileges.
           For Trusted Oracle users getting this error although granted the
           the appropriate privilege at a higher label, ask the database
           administrator to regrant the privilege at the appropriate label.

Answer 1:

你需要:

grant references on "FRED"."ITEMS" TO "BOB"

请参见本 “AskTom”



Answer 2:

要创建一个外键引用在您需要的“参考”特权另一个模式的表:

GRANT REFERENCES ON FRED.ITEMS TO BOB;


文章来源: Foreign keys in alternate schemas with Oracle?