CDB&PDB USERS AND PRIVILLEGE

容器中只有以下DDL操作可以使用container=all|current,其它DDL只能对当前的容器有效:

create user, alter user, create role, grant, revoke

  1. user/role:

comon user/role:只能在cdb$root或application root中创建,即创建时不用指定container=all

local user/role:只能在pdb或application pdb中创建,即创建时也不用指定container=current

Common user/role在所有容器的密码是一致的,不能单独更改;但它们的权限是可以在cdb$root或pdbs中不同的

2. grant&revoke:

默认为container=current

grant:

container=current时可以授权给local user, common user, local role.

    container=all时可以授权给common user, common role.

revoke:

container=current时可收回local user, common user, local role. 它只能收回通过container=current授予的权限,对container=all授予权限无影响

    container=all时可收回common user, common role. 它只能收回通过container=all授予的权限,对container=current授予权限无影响

Container=all不仅表示对当前所有容器操作,对于将来创建的pdbs也生效

Setting CONTAINER to ALL applies the privilege to all existing and future containers;

注:授予对象权限时使用container=all,则必是将common object授予common user,即只能在application root中把sharing object授予common user.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

权限与角色:

  1. CREATE PLUGGABLE DATABASE: 可以执行create/alter pluggable database,授予了还不能执行一般要授予sysdba或sysoper
  2. SET CONTAINER:切换到此容器的权限
  3. PDB_DBA角色:没有系统权限可以执行一些存储过程
  4. CDB_DBA角色:只有set container权限以及查询三张sys表
  5. 从12c开始resouce不会再同时授予unlimited tablespace权限,connect不再只授予create session权限,还多了set container权限

pdb_dba与cdb_dba的权限远小于dba,它们单独授予很难工作

dba角色虽然包含CREATE PLUGGABLE DATABASE与SET CONTAINER, 但在cdb$root中无法通过访问容器视图访问其它pdb的信息(需要设置container_data,很麻烦),因此也无法执行show pdbs,而且不能启停pdbs

可以单个container管理用dba,整个cdb管理用sysdba.

另外application的创建,修改以及在pdbs中的sync均需要dba权限

在CDB对public role授权时建议不要使用container=all,但试了下还是可以使用且生效的:

All privileges that Oracle grants to the PUBLIC role are granted locally.

This feature enables you to revoke privileges or roles that have been granted to the PUBLIC role individually in each PDB as needed. If you must grant any privileges to the PUBLIC role, then grant them locally. Never grant privileges to PUBLIC commonly.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

CONTAINER_DATA:

只能在cdb$root中使用,通过设置common user的container_data属性,来使用户可以通过视图或数据字典查看多个容器信息

creat user c##test identified by oracle;

grant dba to c##test container=all;

conn c##test/oracle

select * from cdb_pdbs;  ---空

conn / as sysdba

Alter user c##test SET CONTAINER_DATA = (cdb$root, pdbnew, deppdb1) FOR cdb_pdbs container=current;   --只能使用container=current

col username format a10

col object_name format a20

col container_name format a10

set linesize 200

select username, OBJECT_NAME,CONTAINER_NAME from dba_container_data where username='C##TEST';

USERNAME   OBJECT_NAME          CONTAINER_

---------- -------------------- ----------

C##TEST    CDB_PDBS             CDB$ROOT

C##TEST    CDB_PDBS             PDBNEW

C##TEST    CDB_PDBS             DEPPDB1

Alter user c##test SET CONTAINER_DATA = (cdb$root, pdbnew, deppdb1) FOR v_$session container=current;   --sys用户要用v_$session, dba用户能用v$session

select username, OBJECT_NAME,CONTAINER_NAME from dba_container_data where username='C##TEST';

USERNAME   OBJECT_NAME          CONTAINER_

---------- -------------------- ----------

C##TEST    V_$SESSION           CDB$ROOT

C##TEST    V_$SESSION           PDBNEW

C##TEST    V_$SESSION           DEPPDB1

C##TEST    CDB_PDBS             CDB$ROOT

C##TEST    CDB_PDBS             PDBNEW

C##TEST    CDB_PDBS             DEPPDB1

忽略指定容器数据字典或视图则表示ALL

Alter user c##test SET CONTAINER_DATA = (cdb$root, pdbnew, deppdb1) container=current; 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Note:

  1. 如果pdb mounted,在cdb$root中create/modify/drop common user,则在pdb open read write时自动同步
  2. 在cdb$root下使用container=all则影响所有pdb且为立即同步

在application root下使用container=all只影响此application root与它的pdbs,且需要在application pdbs下执行alter pluggable database application app$con sync 才会同步

    • 0
      点赞
    • 2
      收藏
      觉得还不错? 一键收藏
    • 0
      评论

    “相关推荐”对你有帮助么?

    • 非常没帮助
    • 没帮助
    • 一般
    • 有帮助
    • 非常有帮助
    提交
    评论
    添加红包

    请填写红包祝福语或标题

    红包个数最小为10个

    红包金额最低5元

    当前余额3.43前往充值 >
    需支付:10.00
    成就一亿技术人!
    领取后你会自动成为博主和红包主的粉丝 规则
    hope_wisdom
    发出的红包
    实付
    使用余额支付
    点击重新获取
    扫码支付
    钱包余额 0

    抵扣说明:

    1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
    2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

    余额充值