How to clone an Oracle PDB (Pluggable Database) for testing
To clone an Oracle PDB for testing, ensure prerequisites like SYSDBA privileges and source PDB availability, then use CREATE PLUGGABLE DATABASE ... FROM to create a copy within the same or another CDB, optionally using NOCOPY or FILE_NAME_CONVERT for efficiency, followed by opening the new PDB and updating configurations for test usage.

To clone an Oracle Pluggable Database (PDB) for testing, you create a copy of an existing PDB within the same or a different Container Database (CDB). This is useful for development, testing, or staging environments. The process requires proper setup and privileges but is straightforward using SQL*Plus or SQL Developer.
Prerequisites
Before cloning, ensure the following:
- You have SYSDBA or equivalent privileges on the CDB.
- The source PDB is in READ ONLY or OPEN mode.
- A new PDB name is chosen and not already in use.
- The target CDB (if different) has compatible character sets and options.
- Proper storage (file system or ASM) is available for the new data files.
Step-by-Step: Clone a PDB Locally
This example shows how to clone a PDB within the same CDB.
- Connect to the CDB as a privileged user:
sqlplus sys@cdb1 as sysdba - Ensure the source PDB is open:
ALTER PLUGGABLE DATABASE pdb_source OPEN; - Issue the CREATE PLUGGABLE DATABASE ... FROM command:
CREATE PLUGGABLE DATABASE pdb_test FROM pdb_source; - Open the new PDB:
ALTER PLUGGABLE DATABASE pdb_test OPEN; - (Optional) Set a new admin password:
ALTER USER pdb_admin IDENTIFIED BY new_password;
Using NOCOPY or FILE_NAME_CONVERT
By default, Oracle copies all data files. You can change this behavior:
-
NOCOPY: Creates a reference without copying files (faster, but source must remain).
Example: CREATE PLUGGABLE DATABASE pdb_test FROM pdb_source NOCOPY; -
FILE_NAME_CONVERT: Manually define file path mapping.
Example: CREATE PLUGGABLE DATABASE pdb_test FROM pdb_source
FILE_NAME_CONVERT = ('/pdb_source/', '/pdb_test/');
Refresh and Usage for Testing
After cloning, consider:
- Running noncdb_to_pdb.sql if the source was a non-CDB (rare in modern setups).
- Updating connection strings in test applications to point to the new PDB service.
- Verifying schema data, users, and roles are correctly copied.
- Isolating test changes—use restore points or drop the PDB after tests if needed.
Cloning a PDB is efficient and fast, especially with filesystem snapshots or storage-level clones in enterprise environments. For repeated test setups, automate the process using scripts.
Basically, just prepare the environment, run the CREATE PLUGGABLE DATABASE command, and open the new instance. It’s reliable and built into Oracle’s multitenant architecture.
The above is the detailed content of How to clone an Oracle PDB (Pluggable Database) for testing. For more information, please follow other related articles on the PHP Chinese website!
Hot AI Tools
Undress AI Tool
Undress images for free
AI Clothes Remover
Online AI tool for removing clothes from photos.
Undresser.AI Undress
AI-powered app for creating realistic nude photos
ArtGPT
AI image generator for creative art from text prompts.
Stock Market GPT
AI powered investment research for smarter decisions
Hot Article
Popular tool
Notepad++7.3.1
Easy-to-use and free code editor
SublimeText3 Chinese version
Chinese version, very easy to use
Zend Studio 13.0.1
Powerful PHP integrated development environment
Dreamweaver CS6
Visual web development tools
SublimeText3 Mac version
God-level code editing software (SublimeText3)
Hot Topics
20441
7
13591
4
Oracle Database Services: How to configure TNSNAMES.ORA? (Connectivity)
Jan 07, 2026 am 02:57 AM
TNSNAMES.ORAisoptionalforbasiclocalconnectionsbutessentialforreliableremotenamedconnectionswithaliasing,failover,orloadbalancing;itmustresideinadirectoryOracleNetlocatesviaTNS_ADMIN,$ORACLE_HOME/network/admin,/etc,or%SYSTEMROOT%,anditsentriesrequirec
Oracle Datapump: How to use EXPDP and IMPDP? (Data Migration)
Jan 13, 2026 am 12:12 AM
EXPDP and IMPDP are operating system commands rather than SQL*Plus commands. They must be called in shell/cmd and rely on the database DIRECTORY object and permissions. The export path must be specified through DIRECTORY. When importing, pay attention to the SCHEMAS mode, NETWORK_LINK restrictions and REMAP parameter prerequisites.
Oracle Window Functions: How to use LEAD and LAG? (Time Series Analysis)
Jan 05, 2026 am 05:24 AM
LEAD and LAG are Oracle window functions, used to obtain the values of offset rows before and after the current row in ORDERBY logical order; ORDERBY must be explicitly specified, PARTITIONBY grouping is supported, the offset is a positive integer, and the default value or NULL is returned when out of bounds.
How to install Oracle Database 19c on Red Hat Linux
Jan 07, 2026 am 12:55 AM
To install Oracle Database 19c, you need to prepare the system: confirm RHEL7/8, x86-64 architecture, at least 4GB memory, 20GB disk space, turn off SELinux and firewall, install dependent packages; create oinstall, dba group and oracle user, create /u01 directory and set permissions; configure kernel parameters number (fs.file-max, kernel.shmmax, etc.) and user resource restrictions (nofile, nproc); unzip the installation file as the oracle user, set the ORACLE_BASE, ORACLE_HOME environment variables, run runInstaller to start the graphical installation, and choose to create a stand-alone machine
How to create and manage users and roles in an Oracle database
Jan 02, 2026 am 01:43 AM
CreateuserswithCREATEUSER,assignprivilegesviaGRANT,andmanageaccessusingroles;forexample,createuserjohnwithquotaandunlockaccount,grantCREATESESSIONandCREATETABLEprivileges,createroleapp_developer,assignprivilegestotherole,grantroletouser,anduseALTERor
Oracle Audit Trail: How to track user activities? (Security)
Jan 16, 2026 am 12:36 AM
Oracle auditing is turned off by default. You must first confirm and enable unified auditing (check V$OPTION and V$DATABASE), and then configure the AUDIT policy; focus on auditing high-risk behaviors such as login failures and privileged operations; check the UNIFIED_AUDIT_TRAIL view in the log and clean it with DBMS_AUDIT_MGMT.
How to connect a Django application to an Oracle database backend
Jan 06, 2026 am 12:51 AM
First install the oracledb package, then configure the DATABASES option in settings.py to use the oracle engine, fill in the correct NAME, USER, HOST and other information, then ensure that the client library is available by installing OracleInstantClient or enabling thick mode, and finally run dbshell and showmigrations to verify the connection.
Oracle PL/SQL Packages: How to group related subprograms? (Modular Programming)
Jan 03, 2026 am 01:02 AM
OraclePL/SQLpackagesenforceencapsulationbyseparatingpublicdeclarations(spec)fromimplementations(body);overloadingrequiresallversionsinbothspecandbody;packagevariablespersistpersessionandrequirecarefulstatemanagement.





