建立、克隆pdb---oracle 12c 學習(1)

lsq_008發表於2014-12-09
SQL> select * from v$version;

BANNER                                                                               CON_ID
-------------------------------------------------------------------------------- ----------
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production              0
PL/SQL Release 12.1.0.2.0 - Production                                                    0
CORE    12.1.0.2.0      Production                                                                0
TNS for Linux: Version 12.1.0.2.0 - Production                                            0
NLSRTL Version 12.1.0.2.0 - Production                                                    0

SQL> select sys_context('userenv','con_name') from dual;

SYS_CONTEXT('USERENV','CON_NAME')
------------------------------------------------------------------------------------------------------------------------------------
CDB$ROOT

SQL> select con_id,dbid,con_uid,guid,name,open_mode,create_scn,total_size,block_size from v$pdbs;

    CON_ID       DBID    CON_UID GUID                             NAME         OPEN_MODE  CREATE_SCN TOTAL_SIZE BLOCK_SIZE
---------- ---------- ---------- -------------------------------- ------------ ---------- ---------- ---------- ----------
         2 4264868981 4264868981 0951B9CFB39C2060E0530100007F6961 PDB$SEED     READ ONLY     1594434  870318080       8192
         3 3977202490 3977202490 09521ABB982E7F0BE0530100007FD46A XJNY         READ WRITE    1753354  917504000       8192

--建立一個新PDB  
SQL> CREATE PLUGGABLE DATABASE wapdb ADMIN USER wapadmin IDENTIFIED BY  wapadmin ;

Pluggable database created.

SQL> select con_id,dbid,con_uid,guid,name,open_mode,create_scn,total_size,block_size from v$pdbs;

    CON_ID       DBID    CON_UID GUID                             NAME       OPEN_MODE  CREATE_SCN TOTAL_SIZE BLOCK_SIZE
---------- ---------- ---------- -------------------------------- ---------- ---------- ---------- ---------- ----------
         2 4264868981 4264868981 0951B9CFB39C2060E0530100007F6961 PDB$SEED   READ ONLY     1594434  870318080       8192
         3 3977202490 3977202490 09521ABB982E7F0BE0530100007FD46A XJNY       READ WRITE    1753354  917504000       8192
         4 4211777660 4211777660 0986C60CA76145FDE0530100007F304E WAPDB      MOUNTED       1896905          0       8192

--克隆一個新pdb
SQL> create pluggable database mbs from wapdb;
create pluggable database mbs from wapdb
*
ERROR at line 1:
ORA-65139: Mismatch between XML metadata file and data file
/home/db/oracle/oradata/SMS/0986C60CA76145FDE0530100007F304E/datafile/o1_mf_system_b856b39h_.dbf for value of fcpsb (1897165 in the
plug XML file, 1904147 in the data file)


嘗試將wapdb以read only模式開啟
SQL> alter session set container=wapdb;

Session altered.

SQL> alter database open read only;

Database altered.

SQL> alter session set container=cdb$root;

Session altered.

SQL> select sys_context('userenv','con_name') from dual;

SYS_CONTEXT('USERENV','CON_NAME')
------------------------------------------------------------------------------------------------------------------------------------
CDB$ROOT

SQL> create pluggable database mbs from wapdb;

Pluggable database created.

SQL> alter pluggable database mbs open;

Warning: PDB altered with errors.

SQL> select con_id,dbid,con_uid,guid,name,open_mode,create_scn,total_size,block_size from v$pdbs;

    CON_ID       DBID    CON_UID GUID                             NAME       OPEN_MODE  CREATE_SCN TOTAL_SIZE BLOCK_SIZE
---------- ---------- ---------- -------------------------------- ---------- ---------- ---------- ---------- ----------
         2 4264868981 4264868981 0951B9CFB39C2060E0530100007F6961 PDB$SEED   READ ONLY     1594434  870318080       8192
         3 3977202490 3977202490 09521ABB982E7F0BE0530100007FD46A XJNY       READ WRITE    1753354  917504000       8192
         4 4211777660 4211777660 0986C60CA76145FDE0530100007F304E WAPDB      READ ONLY     1896905  870318080       8192
         5 1281880106 1281880106 0987D2D2C15B4758E0530100007F4AA4 MBS        READ WRITE    1905674  891289600       8192
可見,在克隆pdb時,需要將源pdb已read only模式開啟

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

相關文章