create user c#xb identified by xb container=all; grant create session,sysoper, create pluggable database to c#xb container=all;
# 必须本地undo模式和归档模式下 archive log list;
col property_name for a30 col property_value for a30 select property_name,property_value from database_properties where property_name='LOCAL_UNDO_ENABLED';
create public database link to_remote connect to c#xb identified by xb using '(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = stbyum)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = cdb1) ) )';
# 测试数据链 sys@ORA12C> select * from dual@to_remote;
D - X
# 检查cdb的本地undo模式和archive log col property_name for a30 col property_value for a30 select property_name,property_value from database_properties where property_name='LOCAL_UNDO_ENABLED';
sys@ORA12C> create pluggable database pdb3 from pdb3@to_remote relocate;
Pluggable database created.
sys@ORA12C> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB12C READ WRITE NO 4 PDB3 MOUNTED
# 这个时候本地新建的pdb3还是mount状态,而远端的pdb3还是读写,可以提供服务 sys@CDB1> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB3 READ WRITE NO sys@CDB1> alter session set container=pdb3;
CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB12C READ WRITE NO 4 PDB3 READ WRITE NO sys@ORA12C> select file#,name from v$datafile where con_id=4;