Monday, January 13, 2014

How To Transfer SCN to Redo Log Sequence

Sometimes we need to know date and redo log sequence from SCN
When we debug, we know SCN, then we need to know what archive logs and log sequence number

ie we have SCN 0x0b09.1c7947c0 . its hex
We converts it  to decimal it is 12133760321472

use below sql to do it

SELECT thread#, name, sequence#, first_time, next_time
   FROM gv$archived_log
  WHERE 12133760321472
BETWEEN first_change# AND next_change#;

Wednesday, November 13, 2013

How To Check User Login Information In The Past

Use DBA_HIST_ACTIVE_SESS_HISTORY:

To get client machine name:
SELECT distinct machine  FROM DBA_HIST_ACTIVE_SESS_HISTORY

To get timeframe
SELECT *   FROM DBA_HIST_ACTIVE_SESS_HISTORY where sql_exec_start  > sysdate -7  order by sql_exec_start desc

To get User name

SELECT  user_id  FROM DBA_HIST_ACTIVE_SESS_HISTORY where sql_exec_start  > sysdate -7  order by sql_exec_start desc

user user_id to get name from dba_users

Tuesday, November 12, 2013

Output v$flash_recovery_area_usage is incorrect

sometimes we clean recovery area manually , delete archive logs, old files ourselves
the output v$flash_recovery_area_usage can be  incorrect.

Use rman to sync the data dictionary

RMAN>CROSSCHECK BACKUP;
RMAN>CROSSCHECK ARCHIVELOG ALL;   (crosscheck won't delete, just mark them)

RMAN>Delete expired backup;     (will delete items which crosscheck fail )
RMAN>Delete expired archivelog all;
RMAN>Delete force obsolete;


RMAN> list backup    (it won't list data copies )
RMAN> list datafilecopy all;
RMAN> crosscheck datafilecopy all;
RMAN> delete datafilecopy all;
RMAN>delete datafilecopy tag=test_copy;

RMAN>Delete archivelog all completed before  'SYSDATE-7';
 
Then
use exec dbms_backup_restore.refreshagedfiles ; 
to refresh

Thursday, October 24, 2013

Email SMTP Host DNS MX Record

Sometimes the mail gateway is configured as MX record
 ie test-mail-router.example.com
You can't get any IP from nslookup from  test-mail-router.example.com
However you can use dig and find hostnames behind MX record
dig  test-mail-router.example.com  mx

How it works ,refer wiki http://en.wikipedia.org/wiki/MX_record