Get the App
SLTechnology News&Howtos  ›  Database  › 

Oracle series: (21) access objects under other users [authorization]

Shulou Source: shulou.com Published: 2022-06-01 14:45:23 10月26日 Update

Statement: scott or hr called user name/scheme name/space name

scott--tiger

hr-----lion

Query who the current user is

show user;

When querying all objects in scott's own table space, you can add or leave the user name select * from emp;

select * from emp;

or

select * from scott.emp;

Unlock hr regular account as sysdba

alter user hr account unlock;

Set the password for the hrregular account as sysdba

alter user hr identified by lion;

When scott queries all tables in the hr table space, the user name must be added

select * from hr.jobs;

By default, each user can only query the permissions of objects in his own space, and cannot query objects in other user spaces.

Grant user scott permission to query objects in all user spaces as sysdba

grant select any table to scott;

As sysdba, revoke the scott user's permission to query objects in all user spaces

revoke select any table from scott;

Scott himself sees the privileges he has.

select * from user_sys_privs;

Navigating from scott user space to sysdba user space

conn / as sysdba;

Navigating from sysdba user space to scott user space

conn scott/tiger;

Navigating from scott user space to hr user space

conn hr/lion;

Query all objects in hruser space

select * from tab;

Navigating from hr user space to scott user space

conn scott/tiger;

In scott user space, query jobs table in hr user space, hr user space name must be added

select * from hr.jobs;

Tags: User space query object permission identity navigation user name normal account password situation scheme role Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi vpn Linux Redmi Huawei