1. 程式人生 > >oracle 18c 18.3 學習之六 create pluggable database 因子 source_file_name_convert

oracle 18c 18.3 學習之六 create pluggable database 因子 source_file_name_convert

os: centos 7.4
db: oracle 18c(18.3)

source_file_name_convert 看官方文件,描述的不清不楚的。下面以一個具體的例子說明下。

create pdb

$ sqlplus / as sysdba;

SQL> CREATE PLUGGABLE DATABASE pdbhuiz 
ADMIN USER pdbadminhuiz IDENTIFIED BY rootroot 
ROLES=(DBA) 
DEFAULT TABLESPACE users LOGGING
        DATAFILE '/u01/app/oracle/oradata/ORCL/pdbhuiz/users01.dbf' SIZE 250M REUSE AUTOEXTEND ON NEXT  1280K MAXSIZE UNLIMITED  EXTENT MANAGEMENT LOCAL  SEGMENT SPACE MANAGEMENT  AUTO
file_name_convert=('/u01/app/oracle/oradata/ORCL/pdbseed/',
                   '/u01/app/oracle/oradata/ORCL/pdbhuiz/')  
STORAGE ( MAXSIZE UNLIMITED 
          MAX_SHARED_TEMP_SIZE UNLIMITED
		 )
TEMPFILE REUSE
PATH_PREFIX = '/u01/app/oracle/oradata/ORCL/pdbhuiz/';

SQL> alter pluggable database pdbhuiz open;


SQL> alter pluggable database pdbhuiz close;


SQL> alter pluggable database pdbhuiz unplug into '/u01/app/oracle/unplug_pdb/PDBHUIZ.xml';


SQL> drop pluggable database pdbhuiz keep datafiles;

mv datafile

移動 pdbhuiz 目錄下的檔案到 /tmp

$ cd /u01/app/oracle/oradata/ORCL/pdbhuiz

$ ls -l
total 993312
-rw-r----- 1 oracle oinstall 367009792 Nov 24 15:26 sysaux01.dbf
-rw-r----- 1 oracle oinstall 283123712 Nov 24 15:26 system01.dbf
-rw-r----- 1 oracle oinstall 104865792 Nov 24 15:26 undotbs01.dbf
-rw-r----- 1 oracle oinstall 262152192 Nov 24 15:26 users01.dbf
-rw-r----- 1 oracle oinstall 65019904  Nov 24 15:26 temp012018-11-22_16-38-22-218-PM.dbf

$ mv ./* /tmp
$ ls -l
total 0
$ ls -lt /tmp
-rw-r-----  1 oracle oinstall 283123712 Nov 24 15:26 system01.dbf
-rw-r-----  1 oracle oinstall 367009792 Nov 24 15:26 sysaux01.dbf
-rw-r-----  1 oracle oinstall 104865792 Nov 24 15:26 undotbs01.dbf
-rw-r-----  1 oracle oinstall 262152192 Nov 24 15:26 users01.dbf
-rw-r-----  1 oracle oinstall 65019904  Nov 24 15:26 temp012018-11-22_16-38-22-218-PM.dbf

以上可以看到 pdbhuiz 的資料檔案已經移動到 /tmp 下了。

recreate(plug) pdb

$ sqlplus / as sysdba;

SQL> CREATE PLUGGABLE DATABASE pdbhuiz 
USING '/u01/app/oracle/unplug_pdb/PDBHUIZ.xml' 
source_file_name_convert=('/u01/app/oracle/oradata/ORCL/pdbhuiz/',
                          '/tmp/') 
MOVE
file_name_convert=('/tmp/',
                   '/u01/app/oracle/oradata/ORCL/pdbhuiz/')  
STORAGE ( MAXSIZE UNLIMITED 
          MAX_SHARED_TEMP_SIZE UNLIMITED
		 )
TEMPFILE REUSE
PATH_PREFIX = '/u01/app/oracle/oradata/ORCL/pdbhuiz/';

檢視目錄檔案

$ ls -lt /tmp
total 0

$ ls -lt /u01/app/oracle/oradata/ORCL/pdbhuiz/
total 993368
-rw-r----- 1 oracle oinstall 367009792 Nov 24 15:36 sysaux01.dbf
-rw-r----- 1 oracle oinstall 283123712 Nov 24 15:36 system01.dbf
-rw-r----- 1 oracle oinstall 104865792 Nov 24 15:36 undotbs01.dbf
-rw-r----- 1 oracle oinstall 262152192 Nov 24 15:36 users01.dbf
-rw-r----- 1 oracle oinstall  65019904 Nov 24 15:36 temp012018-11-22_16-38-22-218-PM.dbf

這下清楚 source_file_name_convert 的含義了吧。