Oracle 12c 使用者的建立

來源:互聯網
上載者:User

Oracle 12c 使用者的建立

Oracle 12c  的賬戶可以分為公用賬戶和本機使用者,共有賬戶是在CDB下建立,可以給所有的PDB使用者使用,本地賬戶是只能在PDB中建立的帳號

建立公用使用者
 alter session set container=CDB$ROOT;
create USER C##u02 identified by oracle  container=all;
建立本機使用者
 alter session set container=pdb4;
create USER u01 identified by oracle  container=current;

SQL> SELECT USERNAME,CON_ID,USER_ID FROM CDB_USERS WHERE USERNAME='U01'; 
USERNAME  CON_ID    USER_ID
------------------------------ ---------- ----------
U01        4 105

在CDB中建立測試帳號
1 在CDB中建立帳號必須以C##開頭
 alter session set container=CDB$ROOT;
SQL> create user orcl identified by a;
create user orcl identified by a
            *
ERROR at line 1:
ORA-65096: invalid common user or role name

SQL> create user p##orcl identified by a;
create user p##orcl identified by a
            *
ERROR at line 1:
ORA-65096: invalid common user or role name

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


SQL> select username from dba_users where username like 'C##%';
USERNAME
--------------------------------------------------------------------------------
C##A

---說明本機使用者不能以C##開頭
 alter session set container=pdb4;
SQL>  create user c##B identified by B;
 create user c##B identified by B
            *
ERROR at line 1:
ORA-65094: invalid local user or role name

SQL> SELECT USERNAME,CON_ID,USER_ID FROM CDB_USERS WHERE USERNAME like 'C##%' ORDER BY USERNAME;
USERNAME  CON_ID    USER_ID
------------------------------ ---------- ----------
C##BOSWLL 4 103
C##BOSWLL 3 110
C##BOSWLL 1 102
C##BOSWLL 5 103
C##U02 4 106
C##U02 5 104
C##U02 1 103
C##U02 3 111

 ---建立公用使用者時,不能在pdb中建立,必須在cdb中建立公用使用者
 SQL>  alter session set container=pdb4;
Session altered.

SQL> create USER C##u02 identified by oracle  container=all;
create USER C##u02 identified by oracle  container=all
                                *
ERROR at line 1:

ORA-65050: Common DDLs only allowed in CDB$ROOT

總結:
1 公用使用者必須以 C##開頭,本機使用者只能以字母開頭,不能以C##使用者開頭
2 建立公用使用者時,必須是在CDB$ROOT
3 如果在PDB中已經存在一個使用者或者角色,則在CDB中不能建立相同的帳號或者角色名稱

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.