Posts

Showing posts from November, 2010

AWR Reports automation

We can find the retention and snap interval from below query. select * from DBA_HIST_WR_CONTROL; DBID SNAP_INTERVAL RETENTION TOPNSQL 3439180179 +00000 01:00:00.0 +00007 00:00:00.0 DEFAULT we want to change the retention to 15 days and intervel to 30 mins. For that we executed below scripts BEGIN DBMS_WORKLOAD_REPOSITORY.modify_snapshot_settings( retention => 21600, -- in minutes interval => 30); END; / ## We can automate this awr report generation process by following scripts. Before we start we need to keep in mind that a table contains username and password of a user who will generate awr report from different databases. Let say the Role is role_awr and the user name is usr_awr. This user and role will need to be created on each database. create role role_awr; GRANT SELECT ON SYS.V_$DATABASE TO role_awr; GRANT SELECT ON SYS.V_$INSTANCE TO role_awr; GRANT EXECUTE ON SYS.DBMS_WORKLOAD_REPOSITORY TO role_awr; GRA

Oracle Job Operations

As a DBA, often I need to deal with Client's Jobs. Sometimes the jobs got hault, needs to break etc etc. Here are some useful commands for this sort of operations. ## Job Owner Schema can do this execute dbms_job.remove(444); execute dbms_job.broken(444, true); ## If Sys User needs to remove the job exec SYS.DBMS_IJOB.REMOVE(444); ## to find which jobs are running SELECT a.sid, c.serial#, a.job, a.failures, to_char(a.this_date, 'mm/dd/yyyy hh:mi pm') startdatetime, b.what FROM dba_jobs_running a, dba_jobs b, v$session c WHERE a.job = b.job AND a.sid = c.sid order by a.this_date ##let say we have only sid and serial and we need to kill the process from both OS and database. So first we need to find out the SPID. this query for any RAC database select P.SPID ,S.SID ,S.SERIAL#, S.SCHEMANAME, S.PROGRAM, S.INST_ID, S.OSUSER, S.STATUS from gv$process p, gv$session s where P.ADDR=S.PADDR and S.SID=888 and s.serial#=9293; ## kill the job al

Redo Log Switch Number

How many Redo Switch Occurred: SELECT trunc(first_time) "Date", to_char(first_time, 'Dy') "Day", count(1) "Total", SUM(decode(to_char(first_time, 'hh24'),'00',1,0)) "h0", SUM(decode(to_char(first_time, 'hh24'),'01',1,0)) "h1", SUM(decode(to_char(first_time, 'hh24'),'02',1,0)) "h2", SUM(decode(to_char(first_time, 'hh24'),'03',1,0)) "h3", SUM(decode(to_char(first_time, 'hh24'),'04',1,0)) "h4", SUM(decode(to_char(first_time, 'hh24'),'05',1,0)) "h5", SUM(decode(to_char(first_time, 'hh24'),'06',1,0)) "h6", SUM(decode(to_char(first_time, 'hh24'),'07',1,0)) "h7", SUM(decode(to_char(first_time, 'hh24'),'08',1,0)) "h8", SUM(decode(to_char(first_time, 'hh24'),'09',1,0)) "h9", SUM(decode(to_char(first_ti