Home > Database > Mysql Tutorial > body text

用display_raw看字段的直方图

WBOY
Release: 2016-06-07 17:35:49
Original
1032 people have browsed it

在看字段的直方图时,高值和低值看不明白,需要转换一下,转换如下。 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;

linux

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!