添加 FK 约束时权限不足 (Oracle)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1262801/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 02:05:17  来源:igfitidea点击:

Insufficient privileges when adding FK constraint (Oracle)

oracleforeign-keys

提问by Steven

ALTER TABLE LAB_ADMIN_USER.TEST_TEMPLATE_ABBR ADD (
   CONSTRAINT TEST_TEMPLATE_ABBR_R01 
FOREIGN KEY (test_template_id) 
REFERENCES LAB_ADMIN.TEST_TEMPLATE (test_template_id)
   ON DELETE CASCADE)

What is the most likely cause of 'ORA=01031: insufficient privileges' when executing the command above? In other words, what permission does LAB_ADMIN_USER most likely not have?

执行上述命令时“ORA=01031:权限不足”的最可能原因是什么?换句话说,LAB_ADMIN_USER 最有可能没有什么权限?

I already created the table successfully and attempted to add the FK constraint as LAB_ADMIN_USER.

我已经成功创建了表并尝试将 FK 约束添加为 LAB_ADMIN_USER。

回答by APC

The table with the primary key is owned by a different schema - LAB_ADMIN. That user must grant REFERENCES on TEST_TEMPLATE to LAB_ADMIN_USER.

带有主键的表由不同的模式 - LAB_ADMIN 所有。该用户必须将 TEST_TEMPLATE 上的 REFERENCES 授予 LAB_ADMIN_USER。

回答by diptiman

From the owning schema execute GRANT REFERENCES ON OWNINGSCHEMA.TABLE TO OTHERSCHEMA;

从拥有架构执行 GRANT REFERENCES ON OWNINGSCHEMA.TABLE TO OTHERSCHEMA;