简体   繁体   中英

Oracle Roles, Privileges, and custom types spread across different schemas

I have a schema that contains the vast majority of tables on my project, DEV2.

Additionally, I have a schema that contains oracle custom types used by DEV2: PUBLIC_TYPES.

I want to be able to create triggers on DEV2 that access the roles in PUBLIC_TYPES, but would prefer to do this with a role, so that when I create DEV3 (a clone of DEV2), I can just grant the role to DEV3 prior to compiling the triggers.

At the moment, if I perform the following:

grant all on public_types.type_name to DEV2;

and then (on the DEV2 user) I type:

desc public_types.type_name;

I get the proper description of the type.

However, if I instead do the following:

create role TABLE_PRIVS;
grant all on public_types.type_name_2 to TABLE_PRIVS;
grant table_privs to DEV2;

(and then switch to my DEV2 user, and desc)

desc public_types.type_name_2

I get

ORA-04043: object public_types.type_name_2 does not exist

What am I missing? I've granted the privilege to a role, and the role to a user. Does this work differently with types?

Thanks in advance!

Try to add role to user as default

grant table_privs to DEV2;
ALTER USER DEV2 DEFAULT ROLE table_privs;

otherwise you need to use SET ROLE

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM