1、将non-CDB数据库开启为read only状态
[oracle@cat1 ~]$ srvctl stop database -db orcl
[oracle@cat1 ~]$ export ORACLE_SID=orcl1
[oracle@cat1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Sun May 1 00:55:41 2005
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup mount
SQL> alter database open read only ;
Database altered.
SQL>
2、生成数据文件等信息的xml文件
SQL> exec dbms_pdb.describe('/tmp/aaa.xml');
PL/SQL procedure successfully completed.
关闭数据库
SQL> shutdown immediate
3、同步到PDB
登录目标库CDB
oracle@cat1 ~]$ export ORACLE_SID=whs11
[oracle@cat1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Tue Nov 24 16:52:59 2020
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> create pluggable database PDB3_WHS using '/tmp/aaa.xml' copy file_name_convert=('+DATA','+DATA1');
Pluggable database created.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB1_WHS READ WRITE NO
4 PDB2_WHS MOUNTED
5 PDB3_WHS MOUNTED
登录pdb,运行noncdb_to_pdb.sql
SQL> alter session set container=PDB3_WHS;
Session altered.
SQL> @?/rdbms/admin/noncdb_to_pdb.sql
.
.
.
.
.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
5 PDB3_WHS MOUNTED
SQL> alter database open;
Database altered.