Monday, January 16, 2012

How to Validate the Restore of Backups

RESTORE VALIDATE and VALIDATE BACKUPSET commands check whether you can restore from your backups.

---------------------------------------------------------
Examples:

RESTORE CONTROLFILE VALIDATE;
RESTORE TABLESPACE SYSTEM VALIDATE;
RESTORE ARCHIVELOG ALL VALIDATE;
---------------------------------------------------------
---------------------------------------------------------
Examples:

VALIDATE BACKUPSET 1121,1122;
---------------------------------------------------------

To Preview Backups Used in Restore Operations.

The RESTORE PREVIEW can be used to any RESTORE operation to produce a detailed report of every backup to be used in the RESTORE operation.
----------------------------------------------------------------
Examples:

RESTORE DATABASE PREVIEW;
RESTORE TABLESPACE users PREVIEW;
RESTORE DATAFILE 3 PREVIEW;
RESTORE ARCHIVELOG FROM LOGSEQ 200 PREVIEW;
RESTORE ARCHIVELOG FROM TIME 'SYSDATE-7' PREVIEW;
RESTORE ARCHIVELOG FROM SCN 234546 PREVIEW;

---------------------------------------------------------------------

Thursday, January 5, 2012

Query to calculate CPU utilisation in a database.

select
ss.username,
se.SID,
VALUE/100 cpu_usage_seconds
from
v$session ss,
v$sesstat se,
v$statname sn
where
se.STATISTIC# = sn.STATISTIC#
and
NAME like '%CPU used by this session%'
and
se.SID = ss.SID
and
ss.status='ACTIVE'
and
ss.username is not null
order by VALUE desc;

----------------------------------------


Select sql_text from v$sql where address=(select sql_address from v$session where paddr=(select addr from v$process where spid= &spid));

Select sql_text from v$sql where address in (select sql_address from v$session where paddr in (select addr from v$process where spid=622666));

Select sql_text from v$sqltext where hash_value=(select sql_hash_value from v$session where paddr=(select addr from v$process where spid=1929696));

Select sql_text from v$sqltext where hash_value in (select sql_hash_value from v$session where paddr in (select addr from v$process where spid=1138912));

select username from v$session where paddr=(select addr from v$process where spid=1138912);

-----------------------------------------------------------