DROP PLUGGABLE DATABASE ... KEEP DATAFILES removes an unplugged PDB's source references while retaining its permanent data files. The PDB's temporary files are deleted. Use this distinction when retiring the source entry during a transfer or preserving an unplugged database for later reuse.
Oracle DBA Lesson 55 Part 1 — Drop the Entry, Keep the Data Files
Why the source still lists an unplugged PDB
Unplugging records that the PDB is unplugged and produces its descriptor. With XML, the descriptor contains metadata, including file locations, while the physical data files remain separate on disk. A .pdb archive packages the descriptor and the PDB files together. This lesson uses the XML route.
The source still describes the PDB with status UNPLUGGED. An unplugged PDB is unavailable for ordinary application work. Dropping is its supported source operation. The source entry must be dropped before plugging the same unplugged PDB back into that CDB.
Preserve the complete permanent file set, including the applicable system, undo, and user tablespace files. A picture of two files only symbolizes that set. Use the actual manifest.
See Removing a PDB.
Check the source identity and state
KEEP DATAFILES applies after the PDB has already been unplugged, once the transfer and recovery preparation is in place. An ordinary PDB that is only closed, or mounted and never unplugged, is ineligible. On RAC, close the PDB on all instances before unplugging. A snapshot-copy PDB has a different storage rule: Oracle requires INCLUDING DATAFILES when dropping one, so this retention path does not apply. Application containers, proxy PDBs, and managed platforms need their own procedure.
For an ordinary PDB, issue the source drop from CDB$ROOT, connected AS SYSDBA or AS SYSOPER, with the common or local administrative grants Oracle documents for the statement. Record the source DB_UNIQUE_NAME, the PDB name, and the full GUID first. Check services, jobs, other consumers, and any shared file ownership. Release source application dependencies, and name an owner and a retention endpoint for the preserved assets, before retiring the source entry.
On the source root connection:
SHOW CON_NAME
SELECT db_unique_name FROM v$database;
SELECT pdb_name, status, RAWTOHEX(guid) AS guid
FROM dba_pdbs
WHERE pdb_name = 'MOVE_PDB';
A matching check for this example looks like this:
| Item | Value |
|---|---|
| Current container | CDB$ROOT |
DB_UNIQUE_NAME | SRC_CDB |
| PDB_NAME | STATUS | GUID |
|---|---|---|
MOVE_PDB | UNPLUGGED | 73B6A01D25E8431A909C6441B16A92E7 |
DB_UNIQUE_NAME identifies the source database. DBA_PDBS, queried from the root, describes its PDBs. STATUS establishes the unplugged prerequisite. The GUID is a globally unique immutable PDB identifier. RAWTOHEX displays the full raw value as hexadecimal for comparison.
Match the full identity against the recorded descriptor, file manifest, and transfer record. Matching only a PDB name can select the wrong database when the same name appears in different CDBs. If the expected row is missing, the state differs, or the identity is uncertain, resolve that discrepancy before proposing a drop.
See DBA_PDBS and V$DATABASE.
What KEEP DATAFILES changes
DROP PLUGGABLE DATABASE move_pdb
KEEP DATAFILES;
The named target alone is selected. KEEP DATAFILES is the default, and writing it explicitly makes the intended retention choice clear. Oracle removes the source control-file references to the dropped PDB and its data files. Its permanent files remain physically on disk. Temporary files are removed because their temporary work is no longer required.
| Asset | Effect of this source drop |
|---|---|
Source references for MOVE_PDB | Removed |
| Permanent PDB data files | Retained |
| PDB tempfiles | Deleted |
| XML descriptor | Preserve it with the retained set. This command does not create a replacement descriptor. |
| Archived redo logs | Not removed by this statement |
| Backup pieces | Not removed by this statement |
The command does not copy the retained data files, create an independent backup, or test recoverability. Its reference removal is DDL, and SQL ROLLBACK cannot undo it.
INCLUDING DATAFILES requests physical data-file deletion as well. That retirement decision is Part 2. Leave it out of this retention workflow.
Preserve a reuse or recovery route
Two later routes need different preparation that is already in place:
| Route | What must already be established |
|---|---|
| Plug the retained set into an appropriate CDB | Descriptor, complete accessible compatible files, release and feature compatibility, required keys or wallet access, correct source paths, supported copy or reuse choices, and a tested integration and application check. |
| Recover from backups | Required backups, archived redo and metadata, their independent availability, and a rehearsed recovery procedure applicable to a dropped PDB and the required recovery point. |
A backup piece remaining on disk is not proof that the complete recovery chain is usable. Follow the rehearsed recovery procedure for the dropped PDB and the required recovery point.
When a target uses NOCOPY, it directly adopts the retained files. They become working target files and can change. If the fallback needs the original preserved state, retain an independent verified copy or another tested recovery route. A different directory name does not establish independence. Existing references from another database are a reason to protect those files, even after the source dictionary stops listing them.
For an encrypted PDB, preserve the required key and wallet material with Oracle's applicable encryption transfer procedure. Keep that material under its existing controls. Leave credentials and key contents out of the change record.
After the source drop, the way back is the tested compatible replug or the rehearsed dropped-PDB recovery route. SQL ROLLBACK cannot recreate the entry. The correct CREATE PLUGGABLE DATABASE clauses depend on file ownership, paths, identity, compatibility, and whether those files are already in use. An unconditional NOCOPY is not a general way to put the entry back.
See Plugging In an Unplugged PDB and CREATE PLUGGABLE DATABASE.
Check removal and retention separately
Repeat the source check:
SELECT pdb_name
FROM dba_pdbs
WHERE pdb_name = 'MOVE_PDB';
The expected result is no target row. This checks source metadata removal. It does not establish that the permanent files exist or that a target is usable.
Reconcile every recorded permanent file and the XML descriptor through the file-system or ASM tooling that manages them. Confirm that required files are present, identify the expected tempfile exception, and investigate any other missing file. Check that other PDBs remain intact and usable. Verify the target or the fallback with its compatibility, integration, identity, service and client, and application-work tests.
Leave files in place when they are absent from DBA_DATA_FILES or the source inventory. They can belong to the retained transfer set or to a target that is already using them. Retire them only through a separate disposition after the documented retention endpoint and dependency review.
Recap
DROP PLUGGABLE DATABASE ... KEEP DATAFILES removes an unplugged ordinary PDB from the source and leaves its permanent data files on disk. Tempfiles are deleted. The XML descriptor, archived redo, and backup pieces stay where they are: the statement does not write a new descriptor or a backup. Match the container, DB_UNIQUE_NAME, PDB name, UNPLUGGED status, and the full GUID before the drop. Afterward, no DBA_PDBS row means the source inventory no longer lists that PDB. Confirm the files and the descriptor on their own. ROLLBACK cannot put the entry back. Plug the retained set with a tested compatible procedure, or recover through a rehearsed dropped-PDB route. NOCOPY adopts the files as working copies that can change, so an independent original is a separate choice. INCLUDING DATAFILES deletes data files and belongs to the other retirement path.
No comments:
Post a Comment