2000字范文,分享全网优秀范文,学习好帮手!
2000字范文 > Oracle 19c用户(user) 授权(grant)及参数(parameter)应用详解

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

时间:2020-08-29 19:50:13

相关推荐

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

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。