欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

用display_raw看字段的直方图

程序员文章站 2024-01-21 09:44:46
...

在看字段的直方图时,高值和低值看不明白,需要转换一下,转换如下。 SQLgt; SELECT column_name, num_distinct n_d,

在看字段的直方图时,高值和低值看不明白,,需要转换一下,转换如下。

SQL> SELECT column_name,
num_distinct n_d,
low_value o_low_value,
display_raw(low_value, data_type) low_value,
high_value o_high_value,
display_raw(high_value, data_type) high_value
FROM user_tab_cols
WHERE table_name = 'T'
and (column_name='OWNER' or column_name='OBJECT_ID'
or column_name='CREATED');


COLUMN_NAM N_D O_LOW_VALU LOW_VALUE O_HIGH_VAL HIGH_VALUE
---------- ------ ---------- ---------- ---------- ----------
OWNER 22 4249 BI 584442 XDB
OBJECT_ID 51136 C103 2 C3071535 62052
CREATED 1395 7869081E0E3319 30-8月-05 7872021C0C152C 28-2月-14

create or replace function display_raw (rawval raw, type varchar2)
return varchar2
is
cn number;
cv varchar2(32);
cd date;
cnv nvarchar2(32);
cr rowid;
cc char(32);
begin
if (type = 'NUMBER') then
dbms_stats.convert_raw_value(rawval, cn);
return to_char(cn);
elsif (type = 'VARCHAR2') then
dbms_stats.convert_raw_value(rawval, cv);
return to_char(cv);
elsif (type = 'DATE') then
dbms_stats.convert_raw_value(rawval, cd);
return to_char(cd);
elsif (type = 'NVARCHAR2') then
dbms_stats.convert_raw_value(rawval, cnv);
return to_char(cnv);
elsif (type = 'ROWID') then
dbms_stats.convert_raw_value(rawval, cr);
return to_char(cnv);
elsif (type = 'CHAR') then
dbms_stats.convert_raw_value(rawval, cc);
return to_char(cc);
else
return 'UNKNOWN DATATYPE';
end if;
end;