September 19, 2012

Unregister Oracle database from recovery catalog when db is unavailable

The normal RMAN method with database target connection

To unregister an Oracle database from a recovery catalog you normally connect to the target database and the recovery catalog using RMAN (recovery manager) and issue the UNREGISTER DATABASE command. Like this.

$ rman 
RMAN> connect target / 
RMAN> connect catalog rcat@rcatdb
RMAN> unregister database;

But what if you want to unregister a database that has been deleted, or is unavailable for other reasons?

Unregistering a database that is not available

It is possible to unregister a database without connecting to the target database. Do this by connecting to the recovery catalog database using SQL*Plus and logging in as the recovery catalog owner.

Query the rc_database view, to find the db_key and dbid of the database that you want to unregister. Then, execute the DBMS_RCVCAT.unregisterdatabase procedure using the information you just gathered as in-parameters and the database will be unregistered.

$ sqlplus rcat@rcatdb
SQL> SELECT db_key, dbid FROM rc_database WHERE name='DB_TO_REMOVE';

--------   -----------
4567       1948934923

SQL> execute DBMS_RCVCAT.unregisterdatabase (4567,1948934923);
PL/SQL procedure successfully completed.

No comments:

Post a Comment