Oracle 19c用户(user)、授权(grant)及参数(parameter)应用详解

1.用户创建
1)全局用户
CBD$ROOT中创建用户默认container=all,且只能创建全局用户(必须以c##开头),该全局用户在CDB$ROOT和所有PDBs中都会被创建,但PDBs中的该全局用户必须另外授权才能访问PDBs中的资源。
PDBs中默认且也只能创建本地用户(一定不能以c##开头)。
[oracle@rac19c1 ~]$ sqlplus / as sysdba
SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT
SQL> 

SQL> create user c##usr1 identified by usr1;
User created.

SQL> create user c##usr2 identified by usr2 container=all;
User created.

SQL> colu username for a30
SQL> select username,con_id,user_id from cdb_users where username like 'C##USR%'; 
USERNAME                           CON_ID    USER_ID
------------------------------ ---------- ----------
C##USR1                                 1        106
C##USR2                                 1        107
C##USR1                                 3        107
C##USR2                                 3        109

2)本地用户
SQL> alter session set container=pdb1;
Session altered.

SQL> create user usr3 identified by usr3;
User created.

SQL> create user usr4 identified by usr4 container=current;
User created.

SQL> select username,con_id,user_id from cdb_users where username like 'USR%';

USERNAME                           CON_ID    USER_ID
------------------------------ ---------- ----------
USR4                                    3        111
USR3                                    3        110

2.用户授权
默认情况下,只会给当前container下用户授权。CDB$ROOT中,也可指定container=all,从而对所有打开的PDBs中存在的该用户进行授权。
[oracle@rac19c1 ~]$ sqlplus / as sysdba
SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT

SQL> grant connect to c##usr1;
Grant succeeded.

SQL> colu grantee for a30
SQL> select grantee,con_id from cdb_role_privs where granted_role='CONNECT' and GRANTEE='C##USR1';

GRANTEE                            CON_ID
------------------------------ ----------
C##USR1                                 1

SQL> grant resource to c##usr1 container=all;
Grant succeeded.

SQL> select grantee,con_id from cdb_role_privs where granted_role='RESOURCE' and GRANTEE='C##USR1';
GRANTEE                            CON_ID
------------------------------ ----------
C##USR1                                 1
C##USR1                                 3

3.参数修改
CDB$ROOT中修改参数,PDBs会继承该参数值;PDB中进行参数修改,会覆盖掉其从CDB$ROOT继承的该参数的值。
SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT

SQL> alter system set open_cursors=800;

System altered.

SQL> show parameter open_cur
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
open_cursors                         integer     800
SQL> 
SQL> 
SQL> 
SQL> alter session set container=pdb1;
Session altered.

SQL> 
SQL> show parameter open_cur
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
open_cursors                         integer     800
SQL> 

SQL> alter system set open_cursors=1000;
System altered.

SQL> show parameter open_cur
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
open_cursors                         integer     1000

SQL> conn / as sysdba
Connected.

SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT
SQL> show parameter open_cur
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
open_cursors                         integer     800

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

lhdz_bj

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值