Thursday, January 4, 2018

Remove the Database From an RMAN Recovery Catalog

Remove the  Database From an RMAN Recovery  Catalog
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Removing the database from catalog is nothing but unregisterring the database from the catalog, below methods will help to unregister the database.


There are multiple ways to unregister a database from an RMAN recovery catalog.


UNREGISTER DATABASE (Catalog and Database)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This option is available from Oracle 10g onward. If you still have access to the database you can start RMAN, connecting to both the target database and the catalog.

rman target=sys/password@DBNAME  catalog=rman/rman@catdb

Below are optional, if you want to perform any cleaning operations, you can use below.

RMAN> LIST BACKUP SUMMARY;
RMAN> DELETE BACKUP DEVICE TYPE SBT;
RMAN> DELETE BACKUP DEVICE TYPE DISK;

then

RMAN> UNREGISTER DATABASE;

OR

RMAN> UNREGISTER DATABASE NOPROMPT;



UNREGISTER DATABASE (Catalog Only)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This option is available from Oracle 10g onward. If you no longer have access to the target database, you can still unregister it from the catalog using the UNREGISTER DATABASE command in RMAN.

Start RMAN, connecting only to the catalog.

rman catalog=rman/rman@catdb
Unregister the database by name.

RMAN> UNREGISTER DATABASE SAMPLE NOPROMPT;



If there is more than one database in the catalog with the same name, you will need to use the DBID to identify the database to unregister. You can find this using the LIST INCARNATION command.

RMAN> LIST INCARNATION OF DATABASE SAMPLE;
Once you have the DBID, you can unregister the database using the following script.

RUN

  SET DBID 152565859654;
  UNREGISTER DATABASE SAMPLE NOPROMPT;
}



DBMS_RCVCAT (Catalog Only)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you no longer have access to the target database, you can still unregister it from the catalog using the DBMS_RCVCAT package in SQL.

Connect to the catalog database using SQL*Plus, then query the DB_KEY and DBID values as follows.

SQL> CONNECT rman/rman@catdb
Connected.

SQL> SELECT db_key, dbid, name FROM rc_database WHERE name = 'SAMPLE';

    DB_KEY       DBID NAME
---------- ---------- --------
     23085 152565859654 SAMPLE

1 row selected.


SQL>

The resulting DB_KEY and DBID can then be used to unregister the database using the DBMS_RCVCAT package.

SQL> EXECUTE dbms_rcvcat.unregisterdatabase(23085 , 152565859654 );

PL/SQL procedure successfully completed.

SQL>


Unregister a Database From an RMAN Recovery Catalog

Unregister a Database From an RMAN Recovery Catalog
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

There are multiple ways to unregister a database from an RMAN recovery catalog.


UNREGISTER DATABASE (Catalog and Database)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This option is available from Oracle 10g onward. If you still have access to the database you can start RMAN, connecting to both the target database and the catalog.

rman target=sys/password@SAMPLE catalog=rman/rman@catdb

Below are optional, if you want to perform any cleaning operations, you can use below.

RMAN> LIST BACKUP SUMMARY;
RMAN> DELETE BACKUP DEVICE TYPE SBT;
RMAN> DELETE BACKUP DEVICE TYPE DISK;

then

RMAN> UNREGISTER DATABASE;

OR

RMAN> UNREGISTER DATABASE NOPROMPT;



UNREGISTER DATABASE (Catalog Only)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This option is available from Oracle 10g onward. If you no longer have access to the target database, you can still unregister it from the catalog using the UNREGISTER DATABASE command in RMAN.

Start RMAN, connecting only to the catalog.

rman catalog=rman/rman@catdb
Unregister the database by name.

RMAN> UNREGISTER DATABASE SAMPLE NOPROMPT;



If there is more than one database in the catalog with the same name, you will need to use the DBID to identify the database to unregister. You can find this using the LIST INCARNATION command.

RMAN> LIST INCARNATION OF DATABASE SAMPLE;
Once you have the DBID, you can unregister the database using the following script.

RUN
{
  SET DBID 152565859654;
  UNREGISTER DATABASE SAMPLE NOPROMPT;
}



DBMS_RCVCAT (Catalog Only)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you no longer have access to the target database, you can still unregister it from the catalog using the DBMS_RCVCAT package in SQL.

Connect to the catalog database using SQL*Plus, then query the DB_KEY and DBID values as follows.

SQL> CONNECT rman/rman@catdb
Connected.

SQL> SELECT db_key, dbid, name FROM rc_database WHERE name = 'SAMPLE';

    DB_KEY       DBID NAME
---------- ---------- --------
     23085 152565859654 SAMPLE

1 row selected.


SQL>

The resulting DB_KEY and DBID can then be used to unregister the database using the DBMS_RCVCAT package.

SQL> EXECUTE dbms_rcvcat.unregisterdatabase(23085 , 152565859654 );

PL/SQL procedure successfully completed.

SQL>



Clean UNINSTALL the oracle binaries from WINDOWS

Clean UNINSTALL the oracle binaries from WINDOWS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Below steps is use to do the clean UNINSTALL the oracle binaries on WINDOWS



Uninstall all Oracle components using the Oracle Universal Installer (OUI).
1. Delete the HKEY_LOCAL_MACHINE/SOFTWARE/ORACLE key which contains registry entries for all Oracle products by using regedit.

2. Delete any references to Oracle services/components in the following registry location: HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/. Looks for key entries that starts with “Ora” which are obviously related to Oracle.

3. Reboot the workstation.

4. Delete the ORACLE_BASE directory. (i.e C:\Oracle)

5. Delete the C:\Program Files\Oracle directory.

6.Empty the temp directory.

7.Empty the recycle bin.


Warning: Editing registry may cause problems to your PC.







Saturday, September 9, 2017

Script to find the database jobs


set lines 300 pages 300
col JOB_NAME for a35
col STATUS for a10
col RUN_MACHINE for a10
col NEXT_START for a15
col LAST_START for a15
col LAST_END for a15
col COMMAND for a40
col OWNER for a15
col JOID for a25
select
 j.job_name, decode(js.status,1,'RUNNING',3,'STARTING',4,'SUCCESS',5,'FAILURE',6,'TERMINATED',7,'ON_ICE',8,'INACTIVE') status,
  j.run_machine,
decode(js.next_start,999999999,null,(to_date('31121969200000','ddmmyyyyhh24miss')+(js.next_start/86400))) next_start,
decode(js.last_start,999999999,null,(to_date('31121969200000','ddmmyyyyhh24miss')+(js.last_start/86400))) last_start,
  decode(js.last_end ,999999999,null,(to_date('31121969200000','ddmmyyyyhh24miss')+(js.last_end /86400))) last_end ,
    j.command, j.joid, j.box_joid, j.owner
  from
   AEDBADMIN.ujo_jobst j
  left join AEDBADMIN.ujo_job b on b.joid = j.box_joid
  inner join AEDBADMIN.ujo_job_status js on j.joid = js.joid
 where
  j.joid = js.joid
and (j.box_joid = 18842 or j.joid = 18842)
   order by instr(j.job_name,'.b')*-1,j.joid;
  
  
  
  

Thursday, June 29, 2017

Get DDL for Primary & Foreign Key constraints.

primary

set pages 9999
select DBMS_METADATA.GET_DDL('CONSTRAINT','&constarnt_name','&owner') from dual;


forgien key
set pages 9999
select DBMS_METADATA.GET_DDL('REF_CONSTRAINT','&constarnt_name','&owner') from dual;