Friday, August 30, 2013

clean up a dropped database from RMAN catalog

RMAN> list db_unique_name all;


List of Databases
DB Key  DB Name  DB ID            Database Role    Db_unique_name
------- ------- ----------------- ---------------  ------------------
68262   DGLOGI   1084485603       PRIMARY          DGLOGI
68262   DGLOGI   1084485603       STANDBY          DG
68262   DGLOGI   1084485603       STANDBY          DGS
1       ORCL     1330909046       PRIMARY          ORCL
261     DG       1716975309       PRIMARY          DG
261     DG       1716975309       STANDBY          DGS
192555  TTS      1769654909       PRIMARY          TTS


#DGLOGI  database was dropped

orarac2poc:DGS:/home/oracle> rcat
orarac2poc:RCAT:/home/oracle> sqlplus / as sysdba

SQL*Plus: Release 11.2.0.2.0 Production on Fri Aug 30 09:54:18 2013

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management,
Data Mining and Real Application Testing options

SYS@RCAT> desc dbms_rcvcat
ERROR:
ORA-04043: object dbms_rcvcat does not exist

# SYS can't access to the package , and it is mentioned in oracle document of PL/SQL package reference.

SYS@RCAT> conn rman
Enter password:
Connected.
RMAN@RCAT> select db_key, dbinc_key, dbid, name from rc_database;

    DB_KEY  DBINC_KEY       DBID NAME
---------- ---------- ---------- --------
    192555     220486 1769654909 TTS
       261       8447 1716975309 DG
     68262      68263 1084485603 DGLOGI
         1          2 1330909046 ORCL

RMAN@RCAT> desc dbms_rcvcat
PROCEDURE ADDDBIDTOIMPORT
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 FIRST                          BINARY_INTEGER          IN
 IDB                            VARCHAR2                IN
 IDBINC                         VARCHAR2                IN
 DBID                           NUMBER                  IN     DEFAULT
 DBNAME                         VARCHAR2                IN     DEFAULT
FUNCTION BEGINARCHIVEDLOGRESYNC RETURNS NUMBER
FUNCTION BEGINBACKUPCORRUPTIONRESYNC RETURNS NUMBER
FUNCTION BEGINBACKUPDATAFILERESYNC RETURNS NUMBER
FUNCTION BEGINBACKUPPIECERESYNC RETURNS NUMBER
FUNCTION BEGINBACKUPREDOLOGRESYNC RETURNS NUMBER
FUNCTION BEGINBACKUPSETRESYNC RETURNS NUMBER
FUNCTION BEGINBACKUPSPFILERESYNC RETURNS NUMBER
FUNCTION BEGINBLOCKCORRUPTIONRESYNC RETURNS NUMBER
...

#but catalog owner can "see" it.

@> conn rman
Connected.
RMAN@RCAT> select db_key, dbid, name from rc_database;

    DB_KEY       DBID NAME
---------- ---------- --------
    192555 1769654909 TTS
       261 1716975309 DG
     68262 1084485603 DGLOGI
         1 1330909046 ORCL

RMAN@RCAT> !ps -ef |grep pmon
grid      2247     1  0 Aug01 ?        00:03:01 asm_pmon_+ASM2
oracle    2798     1  0 Aug01 ?        00:04:51 ora_pmon_ORCL2
oracle    2802     1  0 Aug01 ?        00:04:15 ora_pmon_RCAT
oracle    8553     1  0 Aug21 ?        00:00:38 ora_pmon_DGS
oracle    8974     1  0 Jul30 ?        00:02:14 ora_pmon_TTS
oracle   11882 20904  0 14:58 pts/2    00:00:00 /bin/bash -c ps -ef |grep pmon
oracle   11884 11882  0 14:58 pts/2    00:00:00 grep pmon



RMAN@RCAT> exec dbms_rcvcat.unregisterdatabase(68262,1084485603);

PL/SQL procedure successfully completed.

RMAN@RCAT> select db_key, dbid, name from rc_database;

    DB_KEY       DBID NAME
---------- ---------- --------
    192555 1769654909 TTS
       261 1716975309 DG
         1 1330909046 ORCL