Skip to content

Commit 82438e0

Browse files
committedDec 19, 2012
Stats translation script from Martin Widlake and Gary Myers
1 parent 88857ea commit 82438e0

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed
 

‎col_high_low_val.sql

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
-- col_stats
2+
-- Martin Widlake mdw 21/03/2003
3+
-- MDW 11/12/09 enhanced to include more translations of low_value/high_value
4+
-- pilfered from Gary Myers blog
5+
col owner form a6 word wrap
6+
col table_name form a15 word wrap
7+
col column_name form a22 word wrap
8+
col data_type form a12
9+
col M form a1
10+
col num_vals form 99999,999
11+
col dnsty form 0.9999
12+
col num_nulls form 99999,999
13+
col low_v form a18
14+
col hi_v form a18
15+
col data_type form a10
16+
set lines 110
17+
break on owner nodup on table_name nodup
18+
spool col_stats.lst
19+
select --owner
20+
-- ,table_name
21+
column_name
22+
,data_type
23+
,decode (nullable,'N','Y','N') M
24+
,num_distinct num_vals
25+
,num_nulls
26+
,density dnsty
27+
,decode(data_type
28+
,'NUMBER' ,to_char(utl_raw.cast_to_number(low_value))
29+
,'VARCHAR2' ,to_char(utl_raw.cast_to_varchar2(low_value))
30+
,'NVARCHAR2' ,to_char(utl_raw.cast_to_nvarchar2(low_value))
31+
,'BINARY_DOUBLE',to_char(utl_raw.cast_to_binary_double(low_value))
32+
,'BINARY_FLOAT' ,to_char(utl_raw.cast_to_binary_float(low_value))
33+
,'DATE',to_char(1780+to_number(substr(low_value,1,2),'XX')
34+
+to_number(substr(low_value,3,2),'XX'))||'-'
35+
||to_number(substr(low_value,5,2),'XX')||'-'
36+
||to_number(substr(low_value,7,2),'XX')||' '
37+
||(to_number(substr(low_value,9,2),'XX')-1)||':'
38+
||(to_number(substr(low_value,11,2),'XX')-1)||':'
39+
||(to_number(substr(low_value,13,2),'XX')-1)
40+
, low_value
41+
) low_v
42+
,decode(data_type
43+
,'NUMBER' ,to_char(utl_raw.cast_to_number(high_value))
44+
,'VARCHAR2' ,to_char(utl_raw.cast_to_varchar2(high_value))
45+
,'NVARCHAR2' ,to_char(utl_raw.cast_to_nvarchar2(high_value))
46+
,'BINARY_DOUBLE',to_char(utl_raw.cast_to_binary_double(high_value))
47+
,'BINARY_FLOAT' ,to_char(utl_raw.cast_to_binary_float(high_value))
48+
,'DATE',to_char(1780+to_number(substr(high_value,1,2),'XX')
49+
+to_number(substr(high_value,3,2),'XX'))||'-'
50+
||to_number(substr(high_value,5,2),'XX')||'-'
51+
||to_number(substr(high_value,7,2),'XX')||' '
52+
||(to_number(substr(high_value,9,2),'XX')-1)||':'
53+
||(to_number(substr(high_value,11,2),'XX')-1)||':'
54+
||(to_number(substr(high_value,13,2),'XX')-1)
55+
, high_value
56+
) hi_v
57+
from dba_tab_columns
58+
where owner like upper('&tab_own')
59+
and table_name like upper(nvl('&tab_name','WHOOPS')||'%')
60+
ORDER BY owner,table_name,COLUMN_ID
61+
/
62+
clear colu
63+
spool off
64+
clear breaks

0 commit comments

Comments
 (0)
Please sign in to comment.