oracle12c的CDB和PDB初探

hunterjoy發表於2016-06-22

[oracle@oracle12cs ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Wed Jun 22 15:49:41 2016

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 con_name;

CON_NAME
------------------------------
CDB$ROOT
SQL> alter session set container=pdbndc;     --進入PDB

Session altered.

SQL> show con_name;

CON_NAME
------------------------------
PDBNDC

[oracle@oracle12cs ~]$ sqlplus / as sysdba


SQL*Plus: Release 12.1.0.2.0 Production on Wed Jun 22 15:53:44 2016


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>  select name,cdb from v$database;

NAME      CDB
--------- ---
NDC       YES

SQL> select pdb_id,pdb_name,dbid,status,create_scn from dba_pdbs;
    PDB_ID PDB_NAME                   DBID STATUS    CREATION_SCN
---------- -------------------- ---------- --------- ------------
         3 PDBNDC               4056045727 NORMAL         1740000
         2 PDB$SEED             3164418748 NORMAL         1594403
         4 PDB2                 2424970819 NEW            1746754

    PDB_ID PDB_NAME                   DBID STATUS    CREATION_SCN
---------- -------------------- ---------- --------- ------------
         3 PDBNDC               4056045727 NORMAL         1740000
         2 PDB$SEED             3164418748 NORMAL         1594403

--1直接建立
CREATE PLUGGABLE DATABASE pdb2
ADMIN USER pdb2_admin IDENTIFIED BY oracle
STORAGE (MAXSIZE 2G MAX_SHARED_TEMP_SIZE 100M)
DEFAULT TABLESPACE tbs_pdb2 DATAFILE '/u01/app/oracle/oradata/NDC/datafile/pdb2_001.dbf' SIZE 25M AUTOEXTEND ON;

--2  按照模板建立PDB
SQL> alter pluggable database pdbndc close;
alter pluggable database pdbndc close
*
ERROR at line 1:
ORA-65020: pluggable database PDBNDC already closed

SQL> alter pluggable database pdbndc open read only;

Pluggable database altered.
SQL> create pluggable database pdb2    
  2  from pdbndc
  3  file_name_convert=('/u01/app/oracle/oradata/NDC/35D8EADBC36F2F56E0539B00A8C098CD/datafile/','/u01/app/oracle/oradata/NDC/datafile/pdb2');

SQL> alter pluggable database pdb2 open;

Pluggable database altered.


SQL> alter pluggable database pdb2 close;


Pluggable database altered.

SQL> alter pluggable database pdb2 open;

Pluggable database altered.

SQL> alter pluggable database all close;

Pluggable database altered.

SQL> alter pluggable database all open;

Pluggable database altered.

SQL> alter pluggable database pdb2 close immediate;

Pluggable database altered.

SQL> alter pluggable database all open;

Pluggable database altered.

SQL> select name,open_mode from v$pdbs;


NAME                           OPEN_MODE
------------------------------ ----------
PDB$SEED                       READ ONLY
PDBNDC                         READ WRITE
PDB2                           READ WRITE


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/543979/viewspace-2120722/,如需轉載,請註明出處,否則將追究法律責任。

相關文章