1 Description
An administrator can now create a clone of a pluggable database only with the data model definition. The dictionary data in the source is copied as is but all user-created table and index data from the source is discarded.
12.1.0.2 From the beginning, the clone PDB source, you can copy the data dictionary data source pdb's only through this feature, while ignoring the table and index data created by the user
CREATE PLUGGABLE DATABASE statement can be specified by a NO DATA to exclude data objects. Which will create a PDB very fast.
note:
-
Using this feature, you must use the CREATE PLUGGABLE DATABASE ... FROM statement.
-
This feature will not SYSTEM, SYSAUX take effect, if a user creates an object in both table space, these objects are full of clones, including data.
When using this characteristic, PDB source table can contain the following types:
-
Advanced Queue (AQ) tables
-
Clustered tables
-
Table clusters
Experiment 2
2.1 View current PDB
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 LEI1 READ WRITE YES
2.2 source database PDB create test data
SQL> conn lei/lei@lei1;
Connected.
SQL> create table test_t(id number,name varchar2(50)) tablespace cndba;
Table created.
SQL> insert into test_t values(1,'sihong');
1 row created.
SQL> commit;
Commit complete.
2.3 Cloning of LEI1 SIHONG
SQL> CREATE PLUGGABLE DATABASE sihong FROM lei1
FILE_NAME_CONVERT = ('/u01/app/oracle/oradata/orcl/lei1/','/u01/app/oracle/oradata/orcl/sihong/',
'/u01/app/oracle/oradata/orcl/lei1/o1_mf_cndba_dr8kfogo_.dbf','/u01/app/oracle/oradata/orcl/sihong/cndba01.dbf',
'/u01/app/oracle/product/11.2.0.4/db_1/dbs/file','/u01/app/oracle/oradata/orcl/sihong/file') NO DATA; 2 3 4
Pluggable database created.
Remarks:
During create something wrong, for reference only:
- A space in which a temporary table data file in another directory, given as follows:
SQL> CREATE PLUGGABLE DATABASE sihong FROM lei1
FILE_NAME_CONVERT = ('/u01/app/oracle/oradata/orcl/lei1/', '/u01/app/oracle/oradata/orcl/sihong/') NO DATA; 2
CREATE PLUGGABLE DATABASE sihong FROM lei1
*
ERROR at line 1:
ORA-65005: missing or invalid file name pattern for file -
/u01/app/oracle/product/11.2.0.4/db_1/dbs/file
Workaround: Manually specify the file name
'/u01/app/oracle/product/11.2.0.4/db_1/dbs/file','/u01/app/oracle/oradata/orcl/sihong/file'
- OMF file management data
SQL> CREATE PLUGGABLE DATABASE sihong FROM lei1
FILE_NAME_CONVERT = ('/u01/app/oracle/oradata/orcl/lei1/','/u01/app/oracle/oradata/orcl/sihong/',
'/u01/app/oracle/product/11.2.0.4/db_1/dbs/file','/u01/app/oracle/oradata/orcl/sihong/file') NO DATA; 2 3
CREATE PLUGGABLE DATABASE sihong FROM lei1
*
ERROR at line 1:
ORA-01276: Cannot add file
/u01/app/oracle/oradata/orcl/sihong/o1_mf_cndba_dr8kfogo_.dbf. File has an
Oracle Managed Files file name.
SQL> !oerr ora 01276
01276, 00000, "Cannot add file %s. File has an Oracle Managed Files file name."
// *Cause: An attempt was made to add to the database a datafile, log file,
// control file, snapshot control file, backup control file,
// datafile copy, control file copy or backuppiece with an Oracle
// Managed Files file name.
// *Action: Retry the operation with a new file name.
Solution:
'/u01/app/oracle/oradata/orcl/lei1/o1_mf_cndba_dr8kfogo_.dbf','/u01/app/oracle/oradata/orcl/sihong/cndba01.dbf'
2.4 authentication data
SQL> alter session set container=sihong;
Session altered.
- Data is not over cloning
SQL> select * from lei.test_t;
no rows selected
Reference documents: http://docs.oracle.com/database/121/SQLRF/statements_6010.htm#SQLRF57032