参考官方文档链接:

CDB 模式下,公用用户(Common User)和本地用户(Local User)两个概念被引入进来,公用用户可以在 CDB PDB中同时存在,能够连接 ROOT PDB 进行操作;而本地用户则只在特定的 PDB 中存在,也只能在特定的 PDB 中执行操作。

oracle 12.2 common user and local user
1. 创建公共用户
oracle 12.2 common user and local user

CDB 中创建的公用用户要求以 c##C##开头,并且Oracle会向每个 PDB 中同时创建该用户,如果 PDB 未打开,则创建工作会以任务的方式延后。
oracle 12.2 common user and local user

打开 PDB,则数据库会自动创建改用户
oracle 12.2 common user and local user

2. 创建application common user。   

Oracle Database 12c R2版本中,Oracle带来新的Application Containers特性,该特性对原有的多租户功能进行了增强,在CDB root容器中可以创建一个叫做Application root的容器,类似于CDB root,可在其内创建多个依赖于Application root的Application PDBs。因此有了application common user.
oracle 12.2 common user and local user

通过视图dba_pdbs.application_root字段查看是否是Application root
oracle 12.2 common user and local user

CREATE USER app_admin IDENTIFIED BY app_admin CONTAINER = ALL;

oracle 12.2 common user and local user

3. 创建 local user
oracle 12.2 common user and local user

CDB模式下,CDB$ROOT 中不能创建本地用户或角色
oracle 12.2 common user and local user

只能在PDB中才能创建本地用户,并且连接用户要具有DBA权限才能创建,同时在PDB中不能创建公用用户:
oracle 12.2 common user and local user
oracle 12.2 common user and local user
4.公用角色和本地角色
官方文档参考链接:

https://docs.oracle.com/en/database/oracle/oracle-database/12.2/dbseg/configuring-privilege-and-role-authorization.html#GUID-F87A4196-186D-4D31-83B4-E097325C3A29
oracle 12.2 common user and local user

CDB common user拥有create session权限后,可以登陆包括 Root 在内的任何 Container

公用角色是指在所有 Container 中都可见的角色,这些角色可能包含全局和本地权限。本地角色只能包含本地权限。授予公用角色的公用权限,对于具有该角色的用户在任何可以连接的 Container 中都将具有该权限。

oracle 12.2 common user and local user

同用户管理类似,在 CDB$ROOT 中可以建立公用角色,但是不能创建本地角色,公用角色在每个 PDB 中都存在,同样需要以 c##为前缀开头:
oracle 12.2 common user and local user

application root也可以创建公用角色,但是不能创建本地角色,只能在application pdb下创建本地角色

oracle 12.2 common user and local user
oracle 12.2 common user and local user
不能创建本地角色
oracle 12.2 common user and local user

类似,在PDB中只能创建本地角色,不能创建公共角色

oracle 12.2 common user and local user

CDB 中可以进行权限授予与回收:
oracle 12.2 common user and local user

相关文章: