| Lesson 7 | Recovering an Open Database, Initially Closed |
| Objective | Reopen unaffected database resources and completely recover an offline user datafile when the database is initially closed. |
A storage outage stops your database instance. Investigation identifies a damaged application datafile, while the current control file and the essential files needed to open the container database remain usable. You want to restore access to unaffected data before completing recovery of the damaged file.
This lesson calls that scenario open-database recovery, initially closed. The database starts closed, but eligible resources are opened before media recovery of the isolated file. The file remains offline during restoration and recovery, then returns online after recovery succeeds.
In Oracle AI Database 26ai, the sequence must distinguish the container database, or CDB, from its pluggable databases, or PDBs. Opening CDB$ROOT does not necessarily open the affected PDB. A PDB may remain mounted until an eligible failed file is isolated.
The walkthrough uses APPPDB and its permanent user datafile 12 in USERS, continuing the example from Lesson 6. The names and number are illustrative. Confirm the actual database, container, file, and failure before applying the procedure.
| Scenario | Availability sequence |
|---|---|
| Lesson 5: Closed recovery | Keep the database mounted during recovery; open after recovery succeeds. |
| Lesson 6: Open recovery, initially open | Keep the CDB and PDB open; isolate and recover the affected file. |
| Lesson 7: Open recovery, initially closed | Reopen usable database resources first; recover the affected file while it remains offline. |
The traditional explanation is to mount, isolate eligible damage, open usable data, restore and recover the offline file, and bring it online. The modern example below applies that purpose across separate CDB and PDB states.
This is a teaching description of a recovery scenario, not a special RECOVER command or a deprecated backup technique. Media recovery reconstructs affected datafiles. Online backups, standby databases, and performance repositories serve other purposes and do not make this recovery scenario obsolete.
Assume a single-instance ARCHIVELOG primary CDB with usable root, seed, and other essential files. The current control file and startup configuration survive. A suitable backup and sufficient recovery information are available, including surviving online redo when needed.
The worked branch assumes the CDB root can open while APPPDB remains mounted, and APPPDB can then open after file 12 is taken offline. SYSTEM, SYSAUX, active undo, tempfiles, control-file loss, standby recovery, and RAC procedures are outside this example.
If another damaged file prevents the proposed opening, reassess the recovery scope. A database that started closed does not automatically qualify for this method. The decisive question is whether the usable database scope can operate with the identified file offline.
Confirm administrative access, backup-media availability, restore capacity, storage permissions, and required encryption keys or backup passwords. Choose the operational sequence according to the incident; do not shut down a working database merely to reproduce this lesson's starting state.
Partial availability is an operational choice. Identify which services can perform useful work without the damaged file and which should remain unavailable. A database that accepts connections can still be unsuitable for an application whose normal transactions all depend on objects in that file.
Discuss the expected recovery duration and application dependencies with the service owner. If unaffected functions provide useful access, reopening them can reduce the practical impact of the incident. If every important function depends on the missing data, keeping application access restricted may be clearer while recovery proceeds.
The recovery plan should therefore establish both technical eligibility and the intended service benefit. Record which PDBs and services should open, which data remains unavailable, and how completion will be checked. These decisions make the opening steps purposeful and prevent the successful execution of OPEN from becoming the only measure of progress.
From the correctly configured local CDB environment, establish an administrative SQL*Plus connection:
sqlplus / as sysdba
The example assumes operating-system authentication and a suitably privileged common administrator. Verify the target installation and instance. From a stopped instance, mount the database:
STARTUP MOUNT
Mounting starts the instance and opens its control file without opening the database for normal application use. If the database is already mounted after a failed startup, inspect its state and continue from there. STARTUP FORCE is not a routine prerequisite.
Read the alert log and storage errors. Identify whether the file is missing, physically damaged, or temporarily inaccessible. Repair the underlying storage fault before restoring to the same destination.
At CDB$ROOT, inspect file metadata and recorded recovery requirements:
SELECT con_id, file#, name, status
FROM v$datafile
WHERE file# = 12;
SELECT file#, error, online_status, change#, time
FROM v$recover_file;
Use the file number, filename, and container identifier together with the incident records. Confirm that file 12 belongs to the affected APPPDB and is eligible for isolation. Do not assume that a familiar USERS tablespace name identifies a unique object across the CDB.
V$DATAFILE supports mounted-database diagnosis. DBA_DATA_FILES depends on dictionary access and should not replace it in this mounted-root step. The recovery view uses ONLINE_STATUS, while the separate V$DATAFILE query uses STATUS.
V$RECOVER_FILE can be unreliable with a restored or re-created control file. Even with the current control file, empty results do not establish complete file integrity. Header checks, recovery requirements, and the alert log provide complementary evidence.
Once diagnosis establishes that root opening is appropriate, issue the following in the root SQL*Plus session:
ALTER DATABASE OPEN;
The instance may perform automatic instance recovery as needed after the outage. That activity is distinct from restoring and recovering the damaged application file. Successful root opening does not establish that APPPDB or file 12 is available.
Inspect the actual PDB states:
SELECT con_id, name, open_mode
FROM v$pdbs;
Saved state can reopen PDBs when the CDB restarts. Other PDBs may remain mounted. Open only the intended usable PDBs under the operational plan; an unconditional ALL OPEN command does not resolve a missing-file problem.
The next step assumes APPPDB is still mounted. If it is already open, keep that useful state and isolate the affected file there. If opening reports errors, inspect which container and file they concern before deciding how to continue.
From the common administrative SQL*Plus session, switch to the affected PDB:
ALTER SESSION SET CONTAINER = APPPDB;
SHOW CON_NAME
Confirm the container and file identity before changing file state. If file 12 is not already offline, take it offline:
ALTER DATABASE DATAFILE 12 OFFLINE;
File isolation prevents the database from using that file while restoration replaces its contents. Do not substitute OFFLINE DROP. A failed query does not itself prove that a file is offline, so check status and command success explicitly.
If APPPDB remains mounted and its remaining files meet opening requirements, open it from the current PDB session:
ALTER PLUGGABLE DATABASE OPEN;
Skip this opening command if APPPDB is already open. At this point, the CDB and APPPDB can serve operations using available data while file 12 remains offline. Queries and transactions that depend on the unavailable file can still fail.
Container scope is essential. ALTER DATABASE file clauses operate in the relevant container; issuing them from CDB$ROOT is not interchangeable with issuing them in APPPDB. RMAN recovery by a CDB-wide file number has different connection rules.
Oracle documents these boundaries in ALTER DATABASE and the state operations in ALTER PLUGGABLE DATABASE.
Confirm the storage repair, destination capacity, and backup access before restoration. The main example uses the original recorded filename. Open another terminal in the configured CDB environment and connect RMAN to CDB$ROOT:
rman target /
The earlier SQL*Plus container switch changed only that SQL*Plus session. It does not select the target container for this new RMAN connection. Verify the target and ensure file 12 is the offline file identified during diagnosis.
Restore the affected file:
RESTORE DATAFILE 12;
RMAN selects a suitable backup using its repository and available backup access. It retrieves an earlier physical copy of the datafile. The file must remain offline because that copy still needs recovery before it can participate in normal database operations.
Preserve healthy current datafiles, the current control file, and surviving online redo. One damaged USERS datafile does not require restoring every file in the tablespace or the whole CDB.
If the original destination cannot be reused, plan a relocation with the corresponding metadata update. RMAN SET NEWNAME and SWITCH support suitable relocation workflows. Restoring somewhere new without updating the recorded location leaves the database pointing at the wrong file.
A backup listing alone does not prove that backup media is readable. Use appropriately scoped restore preview or validation when needed to resolve uncertainty. Preview examines repository information; restore validation reads backup contents without writing the restored datafile.
After RESTORE succeeds, continue in the root-connected RMAN session:
RECOVER DATAFILE 12;
RECOVER advances the restored copy using the required recovery information. RMAN can use applicable incremental backups and restore required archived redo from accessible backups. Surviving online redo may contain additional required changes.
Use a session without an earlier point-in-time restriction such as SET UNTIL. Complete recovery has a different objective from deliberately selecting an earlier database state. Keep the file offline until recovery reports success.
Recovery by file number permits root-connected RMAN to address a PDB datafile. If using tablespace names instead, select the appropriate PDB connection because tablespace names can repeat across containers. See Oracle's complete recovery guide.
Review the recovery output before moving on. An accessible directory containing several archived logs is not proof that the full required recovery path exists. If recovery stops, diagnose the reported dependency and preserve the current state while resolving it.
After successful recovery, return to SQL*Plus in APPPDB. Confirm the container and bring the recovered file online:
SHOW CON_NAME
ALTER DATABASE DATAFILE 12 ONLINE;
The CDB and APPPDB are already open. There is no second CDB OPEN step and no RESETLOGS step in this successful complete-recovery example.
Inspect the recovered file and its header in the PDB:
SELECT d.file#, d.name, d.status, h.recover, h.error
FROM v$datafile d
LEFT JOIN v$datafile_header h
ON h.file# = d.file#
WHERE d.file# = 12;
Expected evidence includes ONLINE status, no reported header recovery requirement, and no header error. Investigate missing header information rather than treating a NULL produced by the outer join as proof of health. Combine the result with recovery completion and alert-log review.
Test representative application operations involving the recovered file and confirm intended services. Block-level checks and file status do not establish business correctness. Successful recovery means the file meets the requirements for returning online, not that every database file has an identical header SCN.
Suppose an overnight outage stops the instance and damages storage holding one application datafile. The root's essential files and current control file remain intact. The application file has a usable backup, but retrieving it from backup media will take time.
After mounting and diagnosing, the DBA opens the root. APPPDB remains mounted because its affected file is not usable. The DBA switches to APPPDB, takes the identified file offline, and opens the PDB using its remaining available files.
This can make selected application functions available before the restore finishes. A report whose objects occupy only healthy files may work, while another function that reads the offline file remains unavailable. The benefit depends on actual application dependencies.
RMAN restores and recovers the offline file from a separate root connection. Throughout that work, the file remains isolated. The DBA returns it online only after successful recovery, then checks the previously unavailable application functions.
The important milestones are therefore separate: root opening, PDB opening, file restoration, file recovery, and file availability. Recording each milestone helps operators describe the incident accurately and prevents a partial return of service from being mistaken for complete recovery.
A valid physical backup copy can be restored with an appropriate operating-system or storage utility while the affected file remains offline. Confirm the backup's validity, destination, and permissions. SQL*Plus cannot extract a datafile from an RMAN backup set.
After restoring the copy and updating any changed filename through the appropriate procedure, a suitably privileged SQL*Plus session in APPPDB can apply redo:
RECOVER AUTOMATIC DATAFILE 12
AUTOMATIC selects expected archived-log filenames. It does not retrieve backups or guarantee that no prompt will occur. For staged archived logs, use SET LOGSOURCE or a RECOVER FROM clause as separate alternatives. These settings do not change where newly filled online logs are archived.
After successful media recovery, use the matching ONLINE operation and verification. This is an alternative restoration/recovery method, not extra work to perform after the RMAN procedure has succeeded. Oracle's user-managed recovery procedures explain additional scopes.
If a required archived log is missing, search other copies, backups, and usable recovery paths. V$ARCHIVED_LOG and V$RECOVERY_LOG provide metadata and recovery information; they do not prove that a physical log can be read. Identify redo using the relevant thread, sequence, and incarnation.
A permanently unresolved gap requires reassessing the recoverable endpoint and consistency of the affected scope. Do not automatically switch to incomplete recovery or attempt RESETLOGS. Those choices change the procedure and can involve data loss.
If storage access returns and the current file appears intact, determine whether restoration is still needed. A successful DBVERIFY check does not independently prove that no media recovery is required. File state and redo requirements still matter.
If isolation must expand to a whole tablespace, explain the wider availability impact. OFFLINE TEMPORARY checkpoints online files but can leave recovery requirements for files already offline. OFFLINE IMMEDIATE does not checkpoint and requires media recovery. Recover the required scope before returning the tablespace online.
Reconcile application requests with uncertain outcomes before asking users to retry. A committed operation whose confirmation was lost can be duplicated by blind resubmission. Verify database and application evidence for the affected work.
Resume scheduled backup protection and assess whether the incident requires additional backups under policy. Confirm that repaired storage, relocated files, media access, and encryption credentials are covered by the recovery procedure.
Retain required archived redo and remove staging copies only under the applicable deletion policy. Record the target container and file, backup source, final filename, recovery outcome, and application checks. Avoid blanket cleanup commands in shared temporary directories.
The next lesson concludes the module and reviews the complete-recovery scenarios.