[20181010]12c clone pdb.txt

lfree發表於2018-10-11

[20181010]12c clone pdb.txt

--//從來沒有測試過這個功能,測試看看.

1.環境:
SCOTT@test01p> @ ver1
PORT_STRING                    VERSION        BANNER                                                                               CON_ID
------------------------------ -------------- -------------------------------------------------------------------------------- ----------
IBMPC/WIN_NT64-9.1.0           12.2.0.1.0     Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production              0

SYS@test> show pdbs
    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 TEST01P                        READ WRITE NO

SYS@test> select FILE_NAME,FILE_ID,TABLESPACE_NAME,CON_ID from cdb_data_files;
FILE_NAME                                             FILE_ID TABLESPACE_NAME          CON_ID
-------------------------------------------------- ---------- -------------------- ----------
D:\APP\ORACLE\ORADATA\TEST\TEST01P\UNDOTBS01.DBF           10 UNDOTBS1                      3
D:\APP\ORACLE\ORADATA\TEST\TEST01P\SYSAUX01.DBF             9 SYSAUX                        3
D:\APP\ORACLE\ORADATA\TEST\TEST01P\USERS01.DBF             11 USERS                         3
D:\APP\ORACLE\ORADATA\TEST\TEST01P\SYSTEM01.DBF             8 SYSTEM                        3
D:\APP\ORACLE\ORADATA\TEST\SYSTEM01.DBF                     1 SYSTEM                        1
D:\APP\ORACLE\ORADATA\TEST\SYSAUX01.DBF                     3 SYSAUX                        1
D:\APP\ORACLE\ORADATA\TEST\UNDOTBS01.DBF                    5 UNDOTBS1                      1
D:\APP\ORACLE\ORADATA\TEST\USERS01.DBF                      7 USERS                         1
8 rows selected.

2.克隆外掛資料庫看看.

SYS@test>  alter pluggable database test01p close;
Pluggable database altered.

SYS@test> create pluggable database test02p from test01p FILE_NAME_CONVERT =('D:\APP\ORACLE\ORADATA\TEST\TEST01P\','D:\APP\ORACLE\ORADATA\TEST\TEST02P\') ;
create pluggable database test02p from test01p FILE_NAME_CONVERT =('D:\APP\ORACLE\ORADATA\TEST\TEST01P\','D:\APP\ORACLE\ORADATA\TEST\TEST02P\')
*
ERROR at line 1:
ORA-65036: pluggable database TEST01P not open in required mode

SYS@test> alter pluggable database test01p open read only ;
Pluggable database altered.

SYS@test> show pdbs
    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 TEST01P                        READ ONLY  NO

SYS@test> create pluggable database test02p from test01p FILE_NAME_CONVERT =('D:\APP\ORACLE\ORADATA\TEST\TEST01P\','D:\APP\ORACLE\ORADATA\TEST\TEST02P\') ;
Pluggable database created.

SYS@test> alter pluggable database test02p open read only ;
alter pluggable database test02p open read only
*
ERROR at line 1:
ORA-65085: cannot open pluggable database in read-only mode

SYS@test> alter pluggable database test02p open  ;
Pluggable database altered.

$ sqlplus scott/btbtms@127.0.0.1:1521/test02p
SQL*Plus: Release 12.2.0.1.0 Production on Wed Oct 10 21:33:59 2018
Copyright (c) 1982, 2016, Oracle.  All rights reserved.
Last Successful login time: Wed Oct 10 2018 21:00:55 +08:00
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SCOTT@127.0.0.1:1521/test02p> select * from dept;

    DEPTNO DNAME                LOC
---------- -------------------- -------------
        10 ACCOUNTING           NEW YORK
        20 RESEARCH             DALLAS
        30 SALES                CHICAGO
        40 OPERATIONS           BOSTON

SYS@test> select FILE_NAME,FILE_ID,TABLESPACE_NAME,CON_ID from cdb_data_files order by file_id;
FILE_NAME                                             FILE_ID TABLESPACE_NAME          CON_ID
-------------------------------------------------- ---------- -------------------- ----------
D:\APP\ORACLE\ORADATA\TEST\SYSTEM01.DBF                     1 SYSTEM                        1
D:\APP\ORACLE\ORADATA\TEST\SYSAUX01.DBF                     3 SYSAUX                        1
D:\APP\ORACLE\ORADATA\TEST\UNDOTBS01.DBF                    5 UNDOTBS1                      1
D:\APP\ORACLE\ORADATA\TEST\USERS01.DBF                      7 USERS                         1
D:\APP\ORACLE\ORADATA\TEST\TEST02P\SYSTEM01.DBF            20 SYSTEM                        5
D:\APP\ORACLE\ORADATA\TEST\TEST02P\SYSAUX01.DBF            21 SYSAUX                        5
D:\APP\ORACLE\ORADATA\TEST\TEST02P\UNDOTBS01.DBF           22 UNDOTBS1                      5
D:\APP\ORACLE\ORADATA\TEST\TEST02P\USERS01.DBF             23 USERS                         5
8 rows selected.

SYS@test> alter pluggable database test02p close ;
Pluggable database altered.

SYS@test> alter pluggable database test02p open read only ;
Pluggable database altered.

--//經歷一次open以後,就可以以open read only 開啟.

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

相關文章