Oracle 12C PDB 维护基础介绍(三)

2015-02-03 21:33:44 · 作者: · 浏览: 97
-------------------------CDB$ROOT SQL>
select


con_id,dbid,NAME,OPEN_MODE
from


v$pdbs;? ? CON_ID? ? ?
?DBID NAME? ? ? ? ? ? ? ? ? ? ? ? ?


OPEN_MODE----------
?---------- ------------------------------ ----------? ? ? ? 2
?4048821679 PDB$SEED? ? ? ? ? ? ? ? ? ? ? READ


ONLY? ? ? ? 3
?3313918585 PDB1? ? ? ? ? ? ? ? ? ? ? ? ? READ


WRITE? ? ? ? 4
?3872456618 PDB2? ? ? ? ? ? ? ? ? ? ? ? ? MOUNTED SQL>
create


user
xff identified by


xifenfei;create


user
xff identified by


xifenfei? ? ? ? ? ? *ERROR
at


line 1:ORA-65096:
?invalid common user


or
role name? SQL>
?!oerr ora 6509665096,
?00000, "invalid
?common user or role name"//
?*Cause:? An attempt was made to


create
a common user


or
role with


a name//? ? ? ?
?that wass not


valid for


common users or


roles.? In


addition to//? ? ? ?
?the usual rules for


user
and
role names, common user


and
role //? ? ? ?
?names must start with


C## or


c## and


consist only


of
ASCII //? ? ? ?
?characters.//
?*Action:
?Specify a valid common user


or
role name.// SQL>
create


user
c##xff identified by


xifenfei; User


created. SQL>
SELECT


USERNAME,CON_ID,USER_ID FROM


CDB_USERS WHERE


USERNAME='C##XFF'; USERNAME? ? ?
?CON_ID? ? USER_ID----------
?---------- ----------C##XFF? ? ? ? ? ?
?1? ? ? ? 103C##XFF? ? ? ? ? ?
?3? ? ? ? 104 SQL>
alter


session set


container=pdb1; Session
?altered. SQL>
?show con_name CON_NAME------------------------------PDB1SQL>
create


user?
xff identified by
xifenfei; User


created. SQL>
create


user
c##abc identified by


xifenfei;create


user
c##abc identified by


xifenfei? ? ? ? ? ? *ERROR
at


line 1:ORA-65094:
?invalid local


user
or
role name


创建用户默认的是container=all,在cdb中只能创建全局用户(c##开头),会在cdb和所有的pdb中创建该用户(但是pdb中的全局用户需要另外授权才能够在pdb中访问)。在pdb中只能创建的用户为本地用户


用户授权


SQL>
grant


connect
to
c##xff; Grant


succeeded. SQL>
select


GRANTEE,con_id from


cdb_ROLE_PRIVS where


GRANTED_ROLE='CONNECT'


AND
GRANTEE='C##XFF'; GRANTEE? ? ? ? ? ? ? ? ? ? ? ? ?
?CON_ID------------------------------
?----------C##XFF? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
?1 SQL>
grant


resource to


c##xff container=all; Grant


succeeded. SQL>
select


GRANTEE,con_id from


cdb_ROLE_PRIVS where


GRANTED_ROLE='RESOURCE'


AND?
GRANTEE='C##XFF'; GRANTEE? ? ? ? ? ? ? ? ? ? ? ? ?
?CON_ID------------------------------
?----------C##XFF? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
?1C##XFF? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
?3


用户授权默认情况下是只会给当前container,在cdb中也可以指定container=all,对所有open的pdb且存在该用户都进行授权


修改参数


SQL>
alter


system set


open_cursors=500 container=all; System
?altered. SQL>
?conn sys/xifenfei@pdb1 as


sysdbaConnected.SQL>
?show parameter open_cursors; NAME? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?


TYPE? ? ? ? VALUE------------------------------------
?----------- ------------------------------open_cursors? ? ? ? ? ? ? ? ? ? ? ?
integer? ?


500SQL>
alter


system set


open_cursors=100; alter


system set


open_cursors=100*ERROR
at


line 1:ORA-01219:
database


or
pluggable database


not
open:
?queries allowed on


fixedtables
or


views only? SQL>
alter


database
open; Database


altered. SQL>
alter


system set


open_cursors=100; System
?altered. SQL>
?show parameter open_cursors; NAME? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?


TYPE? ? ? ? VALUE------------------------------------
?----------- ------------------------------open_cursors? ? ? ? ? ? ? ? ? ? ? ?
integer? ?


100SQL>
?conn / as


sysdbaConnected.SQL>
?show parameter open_cursors; NAME? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?


TYPE? ? ? ? VALUE------------------------------------
?----------- ------------------------------open_cursors? ? ? ? ? ? ? ? ? ? ? ?
integer? ?


500


这里可以看到在cdb中修改,pdb会继承进去;如果在pdb中修改会覆盖pdb从cdb中继承的参数含义