将non-CDB置为只读模式:
$ sqlplus '/as sysdba' SQL> select name, decode(cdb, 'YES', 'Multitenant Option enabled', 'Regular 12c Database: ') "Multitenant Option" , open_mode, con_id from v$database; NAME Multitenant Option OPEN_MODE CON_ID --------- -------------------------- -------------------- ---------- TEST Regular 12c Database: READ WRITE 0 SQL> shutdown immediate; SQL> startup open read only;
连接到CDB,创建一个DBLINK,连接到non-cdb:
$ sqlplus '/as sysdba' SQL> select name, decode(cdb, 'YES', 'Multitenant Option enabled', 'Regular 12c Database: ') "Multitenant Option" , open_mode, con_id from v$database; NAME Multitenant Option OPEN_MODE CON_ID --------- -------------------------- -------------------- ---------- ORA12 Multitenant Option enabled READ WRITE 0 SQL> create database link link_test connect to system identified by oracle using 'test';
克隆non-cdb,并执行脚本:
SQL> create pluggable database pdb_test from NON$CDB@link_test create_file_test='/u12/app/oracle/oradata/pdb_test'; SQL> alter session set container=pdb_test; SQL> @$ORACLE_HOME/rdbms/admin/noncdb_to_pdb;
打开克隆好的数据库:
SQL> alter pluggable database pdb_test open;