ORA-01126: Database Must Be Mounted EXCLUSIVE and Not Open
ORA-01126 is thrown when you attempt a database-level operation that requires the database to be mounted in EXCLUSIVE mode while not in an OPEN state. Oracle enforces this restriction to protect the physical database structure during sensitive administrative tasks such as switching archive modes or renaming datafiles. Simply put, if your database is fully open or shared-mounted in a RAC environment, Oracle will block the command and return this error.
Top 3 Causes
1. Attempting MOUNT-Only Commands on an OPEN Database
The most common cause. Commands like ALTER DATABASE ARCHIVELOG or ALTER DATABASE RENAME FILE are only permitted when the database is in MOUNT state, not OPEN.
-- Wrong: Running this on an OPEN database causes ORA-01126
ALTER DATABASE ARCHIVELOG;
-- Correct approach: Shutdown, mount, then execute
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
ALTER DATABASE ARCHIVELOG;
ALTER DATABASE OPEN;
-- Verify
ARCHIVE LOG LIST;
2. Running Exclusive Operations in a RAC Shared-Mount Environment
In Oracle RAC, multiple instances can mount the same database simultaneously. However, certain operations demand a single-instance EXCLUSIVE mount. If another node already has the database mounted or open, ORA-01126 is raised.
-- Check all RAC node statuses
SELECT INST_ID, INSTANCE_NAME, STATUS, PARALLEL
FROM GV$INSTANCE
ORDER BY INST_ID;
-- Shut down all other instances first, then verify EXCLUSIVE mount
-- PARALLEL = 'NO' confirms EXCLUSIVE mode
SELECT INSTANCE_NAME, STATUS, PARALLEL
FROM V$INSTANCE;
-- Now safely run your operation
ALTER DATABASE NOARCHIVELOG;
ALTER DATABASE OPEN;
3. Automation Scripts Missing Pre-flight State Checks
Automated scripts or backup tools (e.g., RMAN wrappers) sometimes skip a database status check and blindly fire MOUNT-only commands against an OPEN database.
-- Add a state check guard to your scripts
DECLARE
v_status VARCHAR2(20);
BEGIN
SELECT STATUS INTO v_status FROM V$INSTANCE;
IF v_status != 'MOUNTED' THEN
RAISE_APPLICATION_ERROR(-20001,
'ORA-01126 risk: Database must be MOUNTED, current status: '
|| v_status);
END IF;
-- Safe to proceed
EXECUTE IMMEDIATE 'ALTER DATABASE ARCHIVELOG';
DBMS_OUTPUT.PUT_LINE('Operation completed successfully.');
END;
/
Quick Fix Solutions
-- Step 1: Check current state
SELECT STATUS, DATABASE_STATUS FROM V$INSTANCE;
-- Step 2: Graceful shutdown
SHUTDOWN IMMEDIATE;
-- Step 3: Start in MOUNT mode only
STARTUP MOUNT;
-- Step 4: Perform your restricted operation
-- Example: rename a datafile
ALTER DATABASE RENAME FILE
'/old/path/users01.dbf'
TO '/new/path/users01.dbf';
-- Step 5: Open the database
ALTER DATABASE OPEN;
Prevention Tips
Always run a pre-check query before any structural DDL. Make
SELECT STATUS, PARALLEL FROM V$INSTANCE(orGV$INSTANCEfor RAC) the very first line of every maintenance script. This takes less than a second and can save hours of unplanned downtime.Schedule MOUNT-only operations inside a formal Maintenance Window. Document these tasks in your Change Management system, confirm all application connections are drained before shutdown, and keep a rollback plan ready. Never perform MOUNT-level changes on a live, user-facing database without prior approval and a tested recovery script.
Related Errors
| Error Code | Description |
|---|---|
| ORA-01507 | Database not mounted |
| ORA-01109 | Database not open |
| ORA-01102 | Cannot mount database in EXCLUSIVE mode |
| ORA-01531 | Database already open by the instance |
📖 Want a more detailed guide?
Check out the full in-depth version (Korean) on oraerror.com — includes detailed analysis, additional SQL examples, and prevention tips.
Top comments (0)