Oracle收集统计信息(Oracle gather statistics)

我正在使用Oracle 11g,我对统计表有一些疑问。

我使用了收集统计数据(100%样本),我看到了一个奇怪的行为。 以下是输出统计表中的值,例如:

Table_name | column_name | low_value | max_value MyTable | A | 30 | 393939393939393939

但是,下一个查询给出了不同的输出:

SELECT MIN(A), MAX(A) FROM MyTable Output: 0 | 99999999999999999

怎么会发生? 请注意,列A是VARCHAR2 ,而此列的值是INT (没关系原因)。 也许类型问题是问题?

I'm using Oracle 11g, and i have some questions regarding the statistics tables.

I used gather statistics (with 100% sample) and i saw a strange behavior. Here is values from the output statistic table for example:

Table_name | column_name | low_value | max_value MyTable | A | 30 | 393939393939393939

However, the next query gives my a different output:

SELECT MIN(A), MAX(A) FROM MyTable Output: 0 | 99999999999999999

How can it happen? Please note that column A is VARCHAR2, while the values of this column are INT (nevermind why). Maybe the type issue is the problem?

最满意答案

Statistics选项卡使用RAW数据类型显示low_value和high_value。

你可以这样试试:

select utl_raw.cast_to_number(low_value), utl_raw.cast_to_number(high_value) from cols where column_name = '<column_name>' and table_name = '<table_name>'

关于Giova

the Statistics tab shows low_value and high_value using the RAW data type.

You can try in this way:

select utl_raw.cast_to_number(low_value), utl_raw.cast_to_number(high_value) from cols where column_name = '<column_name>' and table_name = '<table_name>'

regards Giova

更多推荐