Thursday, December 22, 2011

Running SQL query


------------old

set heading off

select aa from (
select distinct a.sql_id,a.piece,a.sql_text aa,b.first_load_time from v$sqltext a,v$sqlarea b,v$session c where
a.sql_id=b.sql_id
AND c.command = b.command_type
And C.Username = B.Parsing_Schema_Name
and c.sql_hash_value = b.hash_value
and c.sql_address = b.address
and c.username is not null
And B.Parsing_Schema_Name='LDBO'
and c.module='ld.exe'
order by first_load_time desc,sql_id,piece);




-------------------sqlplus

set heading off

select aa from (
select a.sql_id,a.piece,to_char(b.SQL_FULLTEXT) aa,b.first_load_time from v$sqltext a,v$sqlarea b,v$session c where
a.sql_id=b.sql_id
AND c.command = b.command_type
And C.Username = B.Parsing_Schema_Name
and c.sql_hash_value = b.hash_value
and c.sql_address = b.address
and c.username is not null
And B.Parsing_Schema_Name='LDBO'
and c.module='ld.exe'
order by first_load_time desc,sql_id,piece);



------------full sqltext--------at plsql---- sqldeveloper-----

select aa from (
select a.sql_id,a.piece,to_char(b.SQL_FULLTEXT) aa,b.first_load_time from v$sqltext a,v$sqlarea b,v$session c where
a.sql_id=b.sql_id
AND c.command = b.command_type
And C.Username = B.Parsing_Schema_Name
and c.sql_hash_value = b.hash_value
and c.sql_address = b.address
and c.username is not null
And B.Parsing_Schema_Name='LDBO'
and c.module='ld.exe'
order by first_load_time desc,sql_id,piece);


----------------------------sqltext with operation-----------

SELECT s.sql_fulltext, sp.id, sp.parent_id, sp.operation, sp.object_name
FROM v$sqlarea s, v$sql_plan sp ,v$session c
WHERE s.address = sp.address AND s.hash_value = sp.hash_value
AND s.plan_hash_value = sp.plan_hash_value
And C.Username = s.Parsing_Schema_Name
and c.sql_hash_value = s.hash_value
and s.Parsing_Schema_Name='LDBO'
and c.module='ld.exe'
ORDER BY s.plan_hash_value,sp.id;



No comments:

Post a Comment

Followers