如何在oracle 12c中建立普通使用者

來源:互聯網
上載者:User

標籤:

-------如何在oracle 12c中建立普通使用者-------
[[email protected] ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Sun Nov 29 21:43:50 2015

Copyright (c) 1982, 2014, Oracle. All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

--通過con_name能看到當前登入的環境是CDB根庫,CDB包含一個名為PDBORCL的可插拔庫。
SQL> show con_name pdbs;

CON_NAME
------------------------------
CDB$ROOT

CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDBORCL MOUNTED

--建立公用使用者admin,需要使用C##或者c##作為該使用者名稱的開頭。
SQL> create user C##admin identified by Lxf$txx282534;

User created.

--如果使用普通方法建立會報錯
SQL> create user admin identified by Lxf$txx282534;
create user admin identified by Lxf$txx282534
*
ERROR at line 1:
ORA-65096: invalid common user or role name

--建立公用角色, 同公用使用者一樣也需要使用C##或者c##作為角色名稱的開頭。
SQL> create role C##admin01 container=all;

Role created.

--將dba角色授予公用角色, 適用範圍為所有PDB
SQL> grant dba to c##admin01 container=all;

Grant succeeded.

--將公用角色授予公用使用者, 使用範圍為所有PDB
SQL> grant C##admin01 to C##admin container=all;

Grant succeeded.

--下面使用公用使用者分別登入CDB、PDB看看是否通用。
[[email protected] admin]$ sqlplus C##admin/‘Lxf$txx282534‘@pdborcl

SQL*Plus: Release 12.1.0.2.0 Production on Sun Nov 29 22:33:29 2015

Copyright (c) 1982, 2014, Oracle. All rights reserved.

Last Successful login time: Sun Nov 29 2015 22:31:12 +08:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> show con_name;

CON_NAME
------------------------------
PDBORCL


[[email protected] admin]$ sqlplus C##admin/‘Lxf$txx282534‘

SQL*Plus: Release 12.1.0.2.0 Production on Sun Nov 29 22:33:53 2015

Copyright (c) 1982, 2014, Oracle. All rights reserved.

Last Successful login time: Sun Nov 29 2015 22:33:29 +08:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> show con_name;

CON_NAME
------------------------------
CDB$ROOT

在PDB中建立使用者和建立普通使用者就沒有什麼區別了
SQL> create user test identified by test;

User created.
SQL> grant create session to test;

Grant succeeded.
[[email protected] admin]$ sqlplus test/[email protected]

SQL*Plus: Release 12.1.0.2.0 Production on Sun Nov 29 22:17:16 2015

Copyright (c) 1982, 2014, Oracle. All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> show user
USER is "TEST"
SQL> show con_name

CON_NAME
------------------------------
PDBORCL
SQL> exit

--將PDB開啟
SQL> alter pluggable database pdborcl open;
Pluggable database altered.

--切換到PDB容器
SQL> alter session set container=pdborcl;
Session altered.

如何在oracle 12c中建立普通使用者

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.