|
原帖由 Yong Huang 于 2011-7-15 01:40 发表 ![]()
In addition to query length() of the column and add up, you can also rely on the column level stats:
create table testcolusage (x varchar2(4000));
begin for i in 1..100 loop insert into testcolusage values (rpad('x', floor(dbms_random.value(1,4000)))); end loop; end;
/
SQL> select avg(length(x)) from testcolusage;
AVG(LENGTH(X))
--------------
2067.22
exec dbms_stats.gather_table_stats(user, 'TESTCOLUSAGE')
SQL> select avg_col_len from user_tab_columns where table_name = 'TESTCOLUSAGE';
AVG_COL_LEN
------------
2069
SQL> select num_rows from user_tables where table_name = 'TESTCOLUSAGE';
NUM_ROWS
------------
100
So the space used by this column is approximately 206KB (100 rows, one byte for one char in this characterset). You can also add 1 byte for each row to make it more accurate.
Yong Huang
user_tab_columns.avg_col_len可以大概评估出列对空间的需求, |
|