Oracle 12C R2的CDB与PDB简单管理操作(2)

--启动
SYS@testdb> alter pluggable database test_pdb open;
 
Pluggable database altered.
 
SYS@testdb> show pdbs
 
    CON_ID CON_NAME                      OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
        2 PDB$SEED                      READ ONLY  NO
        3 TEST_PDB                      READ WRITE NO
--关闭
SYS@testdb> alter pluggable database test_pdb close;
 
Pluggable database altered.
 
SYS@testdb> show pdbs
 
    CON_ID CON_NAME                      OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
        2 PDB$SEED                      READ ONLY  NO
        3 TEST_PDB                      MOUNTED

7、容器间的切换

SYS@testdb> alter session set container=test_pdb;
 
Session altered.
 
SYS@testdb> show con_name
 
CON_NAME
------------------------------
TEST_PDB

8、使用sql*plus直接连接PDB

查看监听,了解PDB是如何注册的

[oracle@t13s admin]$ lsnrctl status
 
LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 15-MAR-2017 11:23:01
 
Copyright (c) 1991, 2016, Oracle.  All rights reserved.
 
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=bossett13s)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                    LISTENER
Version                  TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date                15-MAR-2017 09:35:52
Uptime                    0 days 1 hr. 47 min. 10 sec
Trace Level              off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File  /oracle/app/oracle/product/12.2/db/network/admin/listener.ora
Listener Log File        /oracle/app/oracle/diag/tnslsnr/bossett13s/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=bossett13s)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "4abd62d724202b74e05358e8ff0a94fe" has 1 instance(s).
  Instance "testdb", status READY, has 1 handler(s) for this service...
Service "test_pdb" has 1 instance(s).
  Instance "testdb", status READY, has 1 handler(s) for this service...
Service "testdb" has 1 instance(s).
  Instance "testdb", status READY, has 1 handler(s) for this service...
Service "testdbXDB" has 1 instance(s).
  Instance "testdb", status READY, has 1 handler(s) for this service...
The command completed successfully

需要配置tns

test_pdb =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.255.232.88)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = test_pdb)
    )
  )

连接

[oracle@t13s admin]$ sqlplus testadm/rF@test_pdb
 
SQL*Plus: Release 12.2.0.1.0 Production on Wed Mar 15 11:30:21 2017
 
Copyright (c) 1982, 2016, Oracle.  All rights reserved.
 
 
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
 
TESTADM@test_pdb>

9、PDB中创建表空间

SYS@testdb> alter session set container=test_pdb
 
Session altered.
 
SYS@testdb> create tablespace users datafile '/data/oradata/testdb/test_pdb/users01.dbf' size 200m;
 
Tablespace created.
 
SYS@testdb> select name from v$tablespace;
 
NAME
------------------------------
SYSTEM
SYSAUX
UNDOTBS1
TEMP
USERS

10、用户管理

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

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/9345714c439e772ac2bbc4a0a0eaf13a.html