0% found this document useful (0 votes)
10 views

DB Scripts 4

The document provides SQL queries to: 1) Summarize archive generation by day including the daily average size in GB from the v$log_history and v$log tables. 2) Identify blocking and blocked sessions from the v$lock table. 3) Report on table or row level locks including the session, table, owner, lock mode, and client process from the gv$locked_object and dba_objects tables.

Uploaded by

Satish PV
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

DB Scripts 4

The document provides SQL queries to: 1) Summarize archive generation by day including the daily average size in GB from the v$log_history and v$log tables. 2) Identify blocking and blocked sessions from the v$lock table. 3) Report on table or row level locks including the session, table, owner, lock mode, and client process from the gv$locked_object and dba_objects tables.

Uploaded by

Satish PV
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Archive Generation :

SELECT A.*,

Round(A.Count#*B.AVG#/1024/1024/1024) Daily_Avg_gb

FROM

(SELECT

To_Char(First_Time,'YYYY-MM-DD') DAY,

Count(1) Count#,

Min(RECID) Min#,

Max(RECID) Max#

FROM v$log_history

GROUP

BY To_Char(First_Time,'YYYY-MM-DD')

ORDER

BY 1 DESC

) A,

(SELECT

Avg(BYTES) AVG#,

Count(1) Count#,

Max(BYTES) Max_Bytes,

Min(BYTES) Min_Bytes

FROM

v$log ) B;

Lock :

select a.SID "Blocking Session", b.SID "Blocked Session"

from v$lock a, v$lock b

where a.SID != b.SID and a.ID1 = b.ID1 and a.ID2 = b.ID2 and

b.request > 0 and a.block = 1;


Table level or row level :

col session_id head 'Sid' form 9999

col object_name head "Table|Locked" form a30

col oracle_username head "Oracle|Username" form a10 truncate

col os_user_name head "OS|Username" form a10 truncate

col process head "Client|Process|ID" form 99999999

col owner head "Table|Owner" form a10

col mode_held form a15

select lo.session_id,lo.oracle_username,lo.os_user_name,

lo.process,do.object_name,do.owner,

decode(lo.locked_mode,0, 'None',1, 'Null',2, 'Row Share (SS)',

3, 'Row Excl (SX)',4, 'Share',5, 'Share Row Excl (SSX)',6, 'Exclusive',

to_char(lo.locked_mode)) mode_held

from gv$locked_object lo, dba_objects do

where lo.object_id = do.object_id

order by 5

You might also like