Enhance Skills Daily

October 03, 2026  ·   · 

Oracle DBA Lesson 55 Part 2 — Retire the PDB and Its Files

DROP PLUGGABLE DATABASE ... INCLUDING DATAFILES removes the target PDB's references from the source control file and deletes its associated permanent data files and tempfiles on disk. Use it when an ordinary disposable PDB and its working files are no longer needed. Identify the exact target, capture its complete file inventory before closing it, and verify both removal and the continued operation of other PDBs.

Oracle DBA Lesson 55 Part 2 — Retire the PDB and Its Files

Set the conditions for an ordinary drop

Connect to CDB$ROOT with SYSDBA or SYSOPER. Oracle documents the common and local grant requirements for the root and for the target. The target here is the ordinary full-copy PDB DISCARD_PDB in the single-instance CDB SRC_CDB. APP_PDB is the continuing application PDB.

  • Release the target's users, services, jobs, integrations, and other dependent work. Arrange the interruption so automation or a service start does not reopen it.
  • Confirm the source database, the target name, and the full GUID against the retirement record. A container ID is useful for querying its current files. A recreated PDB can have a different identity, so keep the full identification record.
  • Capture every permanent data file and tempfile, including the applicable system, user, and local undo files. Check that list against the actual storage and the container configuration. Open required encryption keystores for the inventory, and retain the keys and other assets the recovery plan needs.
  • Rehearse a supported recovery procedure for a dropped PDB, using independent protected artifacts. Record the recovery point and time requirements, backup and redo availability, and the successful rehearsal. A backup listing alone does not show that a restore succeeded.
  • This close-and-drop sequence is for an ordinary full-copy PDB. Snapshot-copy and dependent-clone arrangements use a different procedure. On RAC, close the PDB on every relevant instance. Closing it on one instance leaves this single-instance sequence inapplicable.

See DROP PLUGGABLE DATABASE.

Identify the source and target

From the CDB root:

SHOW CON_NAME
SELECT db_unique_name FROM v$database;

SELECT name, con_id, RAWTOHEX(guid) AS guid, open_mode
FROM v$pdbs
WHERE name = 'DISCARD_PDB';

Expected context:

ItemValue
Current containerCDB$ROOT
DB_UNIQUE_NAMESRC_CDB
NAMECON_IDGUIDOPEN_MODE
DISCARD_PDB5A63D815F47E248C09B129E406D75F3A8READ WRITE

NAME selects the named target, GUID supplies its full global identity, and CON_ID identifies its current container in the CDB views. Compare the full identity with the retirement record. Record the continuing PDB's identity and a working application test as a baseline.

See V$PDBS and V$DATABASE.

Capture the file manifest while the target is open

Use the target's current container ID from that identity query. For DISCARD_PDB, that ID is 5.

SELECT file_name
FROM cdb_data_files
WHERE con_id = 5
ORDER BY file_name;

SELECT file_name
FROM cdb_temp_files
WHERE con_id = 5
ORDER BY file_name;

Store every returned physical file name, with the target identity and the capture time, outside the target file set. Mark which entries are permanent and which are temporary. The file icons in the video symbolize these complete sets, not a particular file count or storage capacity.

CDB_* dictionary views queried from the root return PDB information subject to privileges, CONTAINER_DATA, open state, and restrictions. Capture and validate the manifest before closing the target. An empty result after closing is not evidence that its files were deleted. Investigate incomplete visibility before proceeding.

See CDB_* views, DBA_DATA_FILES, and DBA_TEMP_FILES.

Close only the intended PDB

ALTER PLUGGABLE DATABASE discard_pdb CLOSE IMMEDIATE;

SELECT name, open_mode
FROM v$pdbs
WHERE name IN ('DISCARD_PDB', 'APP_PDB')
ORDER BY name;

Expected state:

NAMEOPEN_MODE
APP_PDBREAD WRITE
DISCARD_PDBMOUNTED

CLOSE IMMEDIATE ends the target's sessions and rolls back uncommitted work. Rollback can take time, so wait until it finishes. The target's physical files remain on disk at this stage. The named statement affects the intended PDB. The CDB and the other PDBs continue operating.

For INCLUDING DATAFILES, Oracle permits the PDB to be MOUNTED or UNPLUGGED. An ordinary mounted PDB can take this clause without an unplug first. The KEEP DATAFILES workflow in Part 1 has its own unplugged-state prerequisite.

See ALTER PLUGGABLE DATABASE and Starting Up and Shutting Down.

Drop the entry and its working files

DROP PLUGGABLE DATABASE discard_pdb INCLUDING DATAFILES;

Oracle removes the target's source control-file references and deletes both its permanent data files and tempfiles. Other PDBs and their files remain intact. SQL ROLLBACK cannot reverse this operation. Restoration requires the prepared, tested procedure and independent assets. This lesson supplies no universal dropped-PDB restore command.

See DROP PLUGGABLE DATABASE and Removing a PDB.

Verify removal and continuing work

Repeat the named inventory query:

SELECT name, open_mode
FROM v$pdbs
WHERE name IN ('DISCARD_PDB', 'APP_PDB')
ORDER BY name;

Expected result:

NAMEOPEN_MODE
APP_PDBREAD WRITE

There is no DISCARD_PDB row. Reconcile each exact recorded target path through the file-system or ASM tooling that manages it. Its permanent files and tempfiles should be absent. Confirm the continuing PDB's physical files and its normal application work, using its usual service and account. If any observation differs, stop further cleanup and investigate the source identity, the target, the manifest, and the storage state. Do not run recursive operating-system deletion to force the expected result.

Archived redo logs and backup pieces are not deleted by this drop. Preserve the required assets and apply their own retention policy separately. Reconcile their presence with the tested recovery procedure and with any other databases that need them.

Services associated with a dropped PDB stay in place. Inspect obsolete service configuration and retire it with the applicable tool: SRVCTL for Oracle Restart or Clusterware-managed services, or DBMS_SERVICE where the service is unmanaged. Preserve services that continuing databases still require. Record the related client, job, and monitoring changes in the retirement plan.

See DROP PLUGGABLE DATABASE and Administering PDBs.

Recap

DROP PLUGGABLE DATABASE ... INCLUDING DATAFILES removes an ordinary PDB from the source control file and deletes that PDB's permanent data files and tempfiles. From CDB$ROOT, match DB_UNIQUE_NAME, the PDB name, the full GUID, and the current CON_ID. Capture the complete manifest from CDB_DATA_FILES and CDB_TEMP_FILES while the target is open. CLOSE IMMEDIATE leaves the target MOUNTED and leaves its files on disk. The drop may run while the PDB is MOUNTED or UNPLUGGED. After the drop, V$PDBS has no row for the target, and each recorded target path is gone. APP_PDB stays available, with its files and application work intact. Archived redo and backup pieces remain under their own retention rules. Services stay until they are retired with SRVCTL or DBMS_SERVICE. ROLLBACK cannot undo the drop.

Quiz

1. When should the CDB dictionary file manifest be captured?

2. What does CLOSE IMMEDIATE do in this procedure?

3. Which target files does INCLUDING DATAFILES delete?

4. Does this drop erase all RMAN backup pieces and archived redo logs?

5. What completes verification beyond the target's missing inventory row?

No comments:

Post a Comment

Vocabulary Revision 6 — Lessons 21 to 24

Lessons 21–24 · 16 words Watch on YouTube Contents https://www.apps-dba.com/ https://www.youtube.com/@EnhanceSkillsDaily Open ...