从模式B表中授予架构c

发布于 2025-01-24 23:03:37 字数 1995 浏览 1 评论 0原文

我有一个应用程序架构 u32_c5 和另一个模式 mig_src ,它具有一些表,然后我们有一个角色 ro_role 我们获得了一些表格来自模式 u32_c5 ro_role 被分配给另一个模式 Mrgo_ro 仅读取。

在这里,我需要从 mig_src mrgo_ro 捕获的表上的表上选择,这是从应用程序schema u32_c5运行的过程,从我可以包含这些赠款的过程。 在生产中,当我试图在下面进行类似的内容时说表或视图(似乎很明显)

u32_c5 执行授予

mig_src.mobile_cellphone_pairings to mrgo_ro;

上的授予选择

我想到的另一种方法是在MIG_SRC模式上在MRGO_RO上创建DB链接,但它也可以在MIG_SRC表上启用读/写操作,而该操作不允许进行生产。

MIG_SRC架构的U32_C5模式上存在DB链接,

因此寻求一种在不创建DB链接的情况下完成上述任务的方法,欢迎任何建议。

需求的示例脚本我想实现

A RO ROLE Created by DBA's 

Create role RO_ROLE;

/* Create application schema, table inside it and grant select on it to RO_ROLE*/

CREATE USER U32_C5 IDENTIFIED BY U32_C5 DEFAULT TABLESPACE; 

GRANT ALTER SESSION TO U32_C5; 
GRANT CREATE SESSION TO U32_C5; 

GRANT CREATE database link TO U32_C5; 

GRANT CREATE table TO U32_C5; 


create table U32_C5_test_tab (id number);

grant select on U32_c5.U32_C5_Test_tab to RO_ROLE;


/* Create Read Only schema, grant RO_ROLE to it */

CREATE USER mrgo_ro IDENTIFIED BY mrgo_ro DEFAULT TABLESPACE;  

GRANT ALTER SESSION TO mrgo_ro; 
GRANT CREATE SESSION TO mrgo_ro; 

grant ro_role to mrgo_ro;

/* Create SRC schema, table inside it */

CREATE USER MIG_SRC IDENTIFIED BY MIG_SRC DEFAULT TABLESPACE; 

GRANT ALTER SESSION TO MIG_SRC; 
GRANT CREATE SESSION TO MIG_SRC; 

GRANT CREATE database link TO MIG_SRC; 

GRANT CREATE table TO MIG_SRC; 

create table mig_src_test_tab (id number);


/* login to Apllication Schema U32_C5 */

sqlplus U32_C5/U32_C5@SID

grant select on mig_src.mig_src_test_tab to mrgo_ro;  -- for me it gives error here at this step table or does not exist 

/* login to Read Only Schema mrgo_ro */

sqlplus mrgo_ro/mrgo_ro@SID

select * from mig_src.mig_src_test_tab;
or 
select * from mig_src_test_tab;

I have an application schema U32_C5 and another schema MIG_SRC which has some tables and then we have a ROLE RO_ROLE on which we have some grants of tables from Schema U32_C5.
The RO_ROLE is assigned to another Schema MRGO_RO which is Read Only.

Here I need to grant select on tables from MIG_SRC to MRGO_RO catch here is that the process which and from where I can include these grants is run from application schema U32_C5 in production so when I tried to to something like below it says table or view does not exists (which seems to be obvious)

execute Grant from U32_C5

grant select on MIG_SRC.MOBILE_CELLPHONE_PAIRINGS to MRGO_RO;

Another way which I think of is creating DB link on MRGO_RO for MIG_SRC Schema but it enables read/write operation as well on MIG_SRC tables which is not allowed on production.

DB Links is present on U32_C5 Schema for MIG_SRC Schema

So looking for a way to accomplish above task without creating DB Link any suggestion is welcome.

Sample Script of requirement what I want to achieve Please Remember I cannot and do not want Login to MIG_SRC and only way I am looking for is to do it by using U32_C5 and without DBA HELP

A RO ROLE Created by DBA's 

Create role RO_ROLE;

/* Create application schema, table inside it and grant select on it to RO_ROLE*/

CREATE USER U32_C5 IDENTIFIED BY U32_C5 DEFAULT TABLESPACE; 

GRANT ALTER SESSION TO U32_C5; 
GRANT CREATE SESSION TO U32_C5; 

GRANT CREATE database link TO U32_C5; 

GRANT CREATE table TO U32_C5; 


create table U32_C5_test_tab (id number);

grant select on U32_c5.U32_C5_Test_tab to RO_ROLE;


/* Create Read Only schema, grant RO_ROLE to it */

CREATE USER mrgo_ro IDENTIFIED BY mrgo_ro DEFAULT TABLESPACE;  

GRANT ALTER SESSION TO mrgo_ro; 
GRANT CREATE SESSION TO mrgo_ro; 

grant ro_role to mrgo_ro;

/* Create SRC schema, table inside it */

CREATE USER MIG_SRC IDENTIFIED BY MIG_SRC DEFAULT TABLESPACE; 

GRANT ALTER SESSION TO MIG_SRC; 
GRANT CREATE SESSION TO MIG_SRC; 

GRANT CREATE database link TO MIG_SRC; 

GRANT CREATE table TO MIG_SRC; 

create table mig_src_test_tab (id number);


/* login to Apllication Schema U32_C5 */

sqlplus U32_C5/U32_C5@SID

grant select on mig_src.mig_src_test_tab to mrgo_ro;  -- for me it gives error here at this step table or does not exist 

/* login to Read Only Schema mrgo_ro */

sqlplus mrgo_ro/mrgo_ro@SID

select * from mig_src.mig_src_test_tab;
or 
select * from mig_src_test_tab;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

扎心 2025-01-31 23:03:37

如果我正确理解您,那么使用Grant Option是您所缺少的。

某人(a)将自己的对象授予其他人(b),并且(b)必须将这些特权“转发”到(c),然后带有赠款选项的有帮助。

document> document>

指定具有赠款选项的指定,以使受赠人能够将对象特权授予其他用户和角色。

限制授予选项的授予期权您只能在授予用户或公共的授予期权时指定,

这意味着您应该直接授予特权,而不是通过角色授予特权。这个事实不一定是一个缺点,因为命名PL/SQL过程,通过角色获得的特权无论如何都无法正常工作,因此您可能无论如何都可以直接获得赠款。


您可能会考虑的其他选项与您所说的内容有关:

当我尝试下面的内容时,它说表或视图不存在

如果您为这些表创建了同义词,那么您就不会遇到这样的错误。


正如您所说,数据库链接不是一个选项 - 通过使用它,您拥有完整访问(因为您必须了解用户名/密码才能创建DB链接,而这并不是真正的仅阅读访问)。

If I understood you correctly, then WITH GRANT OPTION is what you're missing.

Once someone (A) grants privileges on their own objects to someone else (B), and that (B) has to "forward" those privileges to (C), then it is the WITH GRANT OPTION that helps.

Documentation says:

Specify WITH GRANT OPTION to enable the grantee to grant the object privileges to other users and roles.

Restriction on Granting WITH GRANT OPTION You can specify WITH GRANT OPTION only when granting to a user or to PUBLIC, not when granting to a role.

It means that you should grant privileges directly, not via role. That fact doesn't have to be a drawback because of named PL/SQL procedures, where privileges acquired via roles won't work anyway, so you might end up in direct grants anyway.


Other option - which you might consider - is related to what you said:

when I tried to to something like below it says table or view does not exists

If you created a synonym for those tables, then you wouldn't get such an error.


Database link isn't an option, as you said - by using it, you have full access (as you have to know username/password to create the DB link, and that isn't really read only access).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文