"
V$SQLTEXT_with_newlines
ops$tkyte@ORA817.US.ORACLE.COM> desc v$sqltext_with_newlines;
Name Null? Type
----------------------------------- -------- ------------------------
ADDRESS RAW(4)
HASH_VALUE NUMBER
COMMAND_TYPE NUMBER
PIECE NUMBER
SQL_TEXT VARCHAR2(64)
"
can HASH_VALUE use to identified an unique queries statement? Becuase STATSPACK only gives the Hash Value for a query.
Having that said, I have tried the following query, found the hash value and then use the view to find whole query. The outcome was very confussion:
select (select
decode(extent_management,'LOCAL','*','') from dba_tablespaces where
tablespace_name = b.tablespace_name)
|| nvl(b.tablespace_name, nvl(a.tablespace_name,'UNKOWN')) name,
kbytes_alloc kbytes,
kbytes_alloc-nvl(kbytes_free,0) used,
nvl(kbytes_free,0) free,
((kbytes_alloc-nvl(kbytes_free,0))/ kbytes_alloc)*100 pct_used,
nvl(largest,0) largest,
nvl(kbytes_max,kbytes_alloc) Max_Size,
decode( kbytes_max, 0, 0, (kbytes_alloc/kbytes_max)*100) pct_max_used
from ( select sum(bytes)/1024 Kbytes_free,
max(bytes)/1024 largest,
tablespace_name
from sys.dba_free_space
group by tablespace_name ) a,
( select sum(bytes)/1024 Kbytes_alloc,
sum(maxbytes)/1024 Kbytes_max,
tablespace_name
from sys.dba_data_files
group by tablespace_name
select sum(bytes)/1024 Kbytes_alloc,
sum(maxbytes)/1024 Kbytes_max,
tablespace_name
from sys.dba_temp_files
group by tablespace_name )b
where a.tablespace_name (+) = b.tablespace_name
order by &1
/
SQL> select *
2 from (
3 select piece,address, hash_value,
4 lag(sql_text) over (partition by address, hash_value order by piece) ||
5 sql_text ||
6 lead(sql_text) over (partition by address, hash_value order by piece)
7 sql_text
8 from v$sqltext_with_newlines
9 )
10 where hash_value=4167100631
11 /
PIECE ADDRESS HASH_VALUE
---------- -------- ----------
SQL_TEXT
------------------------------------------------------------------------------------------------------------------------------------
0 81178600 4167100631
select (select
decode(extent_management,'LOCAL','*','') from dba_tablespaces where
tablespace_name = b.tablespace_name)
1 81178600 4167100631
select (select
decode(extent_management,'LOCAL','*','') from dba_tablespaces where
tablespace_name = b.tablespace_name)
|| nvl(b.tablespace_name, nvl(a.tablespace_name,'UNKOWN')) nam
2 81178600 4167100631
dba_tablespaces where
tablespace_name = b.tablespace_name)
|| nvl(b.tablespace_name, nvl(a.tablespace_name,'UNKOWN')) name,
kbytes_alloc kbytes,
kbytes_alloc-n
3 81178600 4167100631
|| nvl(b.tablespace_name, nvl(a.tablespace_name,'UNKOWN')) name,
kbytes_alloc kbytes,
kbytes_alloc-nvl(kbytes_free,0) used,
nvl(kbytes_free,0) free,
4 81178600 4167100631
e,
kbytes_alloc kbytes,
kbytes_alloc-nvl(kbytes_free,0) used,
nvl(kbytes_free,0) free,
((kbytes_alloc-nvl(kbytes_free,0))/ kbytes_alloc)*100
5 81178600 4167100631
vl(kbytes_free,0) used,
nvl(kbytes_free,0) free,
((kbytes_alloc-nvl(kbytes_free,0))/ kbytes_alloc)*100 pct_used,
nvl(largest,0) largest,
nv
6 81178600 4167100631
((kbytes_alloc-nvl(kbytes_free,0))/ kbytes_alloc)*100 pct_used,
PIECE ADDRESS HASH_VALUE
---------- -------- ----------
SQL_TEXT
------------------------------------------------------------------------------------------------------------------------------------
nvl(largest,0) largest,
nvl(kbytes_max,kbytes_alloc) Max_Size,
decode( kbytes
7 81178600 4167100631
pct_used,
nvl(largest,0) largest,
nvl(kbytes_max,kbytes_alloc) Max_Size,
decode( kbytes_max, 0, 0, (kbytes_alloc/kbytes_max)*100) pct_max_used
from
8 81178600 4167100631
l(kbytes_max,kbytes_alloc) Max_Size,
decode( kbytes_max, 0, 0, (kbytes_alloc/kbytes_max)*100) pct_max_used
from ( select sum(bytes)/1024 Kbytes_free,
9 81178600 4167100631
_max, 0, 0, (kbytes_alloc/kbytes_max)*100) pct_max_used
from ( select sum(bytes)/1024 Kbytes_free,
max(bytes)/1024 largest,
tablespa
10 81178600 4167100631
( select sum(bytes)/1024 Kbytes_free,
max(bytes)/1024 largest,
tablespace_name
from sys.dba_free_space
group
11 81178600 4167100631
max(bytes)/1024 largest,
tablespace_name
from sys.dba_free_space
group by tablespace_name ) a,
( select sum(bytes)/1024 Kbytes_
12 81178600 4167100631
ce_name
from sys.dba_free_space
group by tablespace_name ) a,
( select sum(bytes)/1024 Kbytes_alloc,
PIECE ADDRESS HASH_VALUE
---------- -------- ----------
SQL_TEXT
------------------------------------------------------------------------------------------------------------------------------------
sum(maxbytes)/1024 Kbytes_max
13 81178600 4167100631
by tablespace_name ) a,
( select sum(bytes)/1024 Kbytes_alloc,
sum(maxbytes)/1024 Kbytes_max,
tablespace_name
from
14 81178600 4167100631
alloc,
sum(maxbytes)/1024 Kbytes_max,
tablespace_name
from sys.dba_data_files
group by tablespace_name
15 81178600 4167100631
,
tablespace_name
from sys.dba_data_files
group by tablespace_name
union all
select sum(bytes)/1024 Kbytes_alloc,
16 81178600 4167100631
sys.dba_data_files
group by tablespace_name
union all
select sum(bytes)/1024 Kbytes_alloc,
sum(maxbytes)/1024 Kbytes_max,
17 81178600 4167100631
union all
select sum(bytes)/1024 Kbytes_alloc,
sum(maxbytes)/1024 Kbytes_max,
tablespace_name
from sys.dba_te
18 81178600 4167100631
PIECE ADDRESS HASH_VALUE
---------- -------- ----------
SQL_TEXT
------------------------------------------------------------------------------------------------------------------------------------
sum(maxbytes)/1024 Kbytes_max,
tablespace_name
from sys.dba_temp_files
group by tablespace_name )b
where a.tabl
19 81178600 4167100631
tablespace_name
from sys.dba_temp_files
group by tablespace_name )b
where a.tablespace_name (+) = b.tablespace_name
order by '%'
20 81178600 4167100631
mp_files
group by tablespace_name )b
where a.tablespace_name (+) = b.tablespace_name
order by '%'
21 rows selected.
SQL>
-------
If you put them together by PIECE, then it does not match the original.