前置条件 Prerequisites for the Open Mode of the Source PDB
- The source PDB must not be closed.
- If the remote CDB is not in local undo mode, then the source PDB must be open in read-only mode.
- If the remote CDB is not in ARCHIVELOG mode, then the source PDB must be open in read-only mode.
- If you are creating a refreshable PDB, then the source PDB must be in ARCHIVELOG mode and local undo mode.
Prerequisites for the Database Link
The following prerequisites must be met:
- A database link must enable a connection from the destination CDB (the CDB to which the PDB is being cloned) to the PDB in the source CDB.
- The database link can connect as a common user to the root of the source CDB, or as a common or local user to the source PDB. The source PDB can be either a standard PDB or application PDB.
- The user account specified in the database link must have either of the following privileges:
- The CREATE PLUGGABLE DATABASE privilege, granted either commonly or locally, on the source PDB
- The SYSOPER privilege
- In an Oracle Data Guard environment, if you are performing a remote clone of a PDB into a primary CDB, then on the standby CDB set the STANDBY_PDB_SOURCE_FILE_DBLINK initialization parameter. This parameter specifies the name of the database link used in CREATE PLUGGABLE DATABASE ... FROM dblink. The standby CDB attempts to copy the data files from the source PDB referenced in the database link, but only if the source PDB is open in read-only mode. Otherwise, you must copy data files to the Oracle Managed Files location on the standby CDB.
To clone a remote PDB:
- In SQL*Plus, ensure that the current container is the root of the target CDB or the application root of the target application container.
- Run the CREATE PLUGGABLE DATABASE statement, and specify the source PDB in the FROM clause. Specify other clauses when required.
- After you create the PDB, it is in mounted mode, and its status is NEW. You can view the open mode of a PDB by querying the OPEN_MODE column in the V$PDBS view. You can view the status of a PDB by querying the STATUS column of the CDB_PDBS or DBA_PDBS view.
- A new default service is created for the PDB. The service has the same name as the PDB and can be used to access the PDB. Oracle Net Services must be configured properly for clients to access this service.
- Note:If an error is returned during PDB creation, then the PDB being created might be in an UNUSABLE state. You can check the PDB state by querying the CDB_PDBS or DBA_PDBS view, and you can learn more about PDB creation errors by checking the alert log. An unusable PDB can only be dropped, and it must be dropped before a PDB with the same name as the unusable PDB can be created.
Open the new PDB in read/write mode.
- You must open the new PDB in read/write mode for Oracle Database to complete the integration of the new PDB into the CDB. An error is returned if you attempt to open the PDB in read-only mode. After the PDB is opened in read/write mode, its status is NORMAL.
配置refreshable pdb
SQL> create user cloneuser identified by cloneuser ;
SQL> grant dba to cloneuser ;
SQL> grant create pluggable database to cloneuser
- 在目标数据库CDB中创建指向源PBD的dblink
CREATE public DATABASE LINK ocipdb1
CONNECT TO Admin IDENTIFIED BY P6Test_123
USING '(DESCRIPTION=
(ADDRESS=(PROTOCOL=TCP)(HOST=158.101.78.182)(PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=pdb1.sub12260703470.vcna.oraclevcn.com))
)';
create pluggable database pdb2 from pdb1@ocipdb1 refresh mode every 10 minutes;
select pdb_id, pdb_name, status, refresh_mode,refresh_interval from cdb_pdbs;
ALTER PLUGGABLE DATABASE pdb2 REFRESH MODE EVERY 1 MINUTES;
ALTERPLUGGABLE DATABASE pdb2 REFRESH MODE manual;
alter pluggable database pdb2 close immediate;
alter pluggable database pdb2 refresh;
alter pluggable database pdb2 read only;
sql command
show con_name; -- 查看当前所在容器位置
show pdbs; -- 查看所有的PDB
alter pluggable database all open; -- 打开所有PDB
alter pluggable database pdb2 open; -- 打开PDB2
alter pluggable database pdb2 open read only; -- 打开PDB2 read only
alter pluggable database pdb2 close immediate; -- 关闭pdb2数据库
Oracle clone pdb doc
tencent clone pdb
前置条件 Prerequisites for the Open Mode of the Source PDB
Prerequisites for the Database Link
The following prerequisites must be met:
To clone a remote PDB:
Open the new PDB in read/write mode.
配置refreshable pdb
sql command
Oracle clone pdb doc
tencent clone pdb