[20140505]刪除直方圖_delete histogram
[20140505]刪除直方圖_delete histogram.txt
昨天看了
介紹刪除直方圖的方法,這樣比較快捷.
SCOTT@test> @ver
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
SCOTT@test> create table t as select rownum id1 , mod(rownum,100)+1 id2, 'test' name from dual connect by level<=1e4;
Table created.
SCOTT@test> execute dbms_stats.gather_table_stats(user,'t',cascade=>true,method_opt=>'for all columns size 1,for columns id1 size 254 ,for columns id2 size 254');
PL/SQL procedure successfully completed.
SCOTT@test> select column_name,num_distinct,histogram from dba_tab_columns where owner=user and table_name='T';
COLUMN_NAME NUM_DISTINCT HISTOGRAM
-------------------- ------------ ---------------
ID1 10000 HEIGHT BALANCED
ID2 100 FREQUENCY
NAME 1 NONE
-- Jonathan Lewis的方法,
declare
srec dbms_stats.statrec;
m_distcnt number;
m_density number;
m_nullcnt number;
m_avgclen number;
n_array dbms_stats.numarray;
begin
dbms_stats.get_column_stats(
ownname => user,
tabname => 't',
colname => 'id1',
distcnt => m_distcnt,
density => m_density,
nullcnt => m_nullcnt,
srec => srec,
avgclen => m_avgclen
);
srec.bkvals := null;
srec.novals := dbms_stats.numarray(
utl_raw.cast_to_number(srec.minval),
utl_raw.cast_to_number(srec.maxval)
);
srec.epc := 2;
dbms_stats.prepare_column_values(srec, srec.novals);
m_density := 1/m_distcnt;
dbms_stats.set_column_stats(
ownname => user,
tabname => 't',
colname => 'id1',
distcnt => m_distcnt,
density => m_density,
nullcnt => m_nullcnt,
srec => srec,
avgclen => m_avgclen
);
exception
when others then
raise; -- should handle div/0
end;
/
SCOTT@test> select column_name,num_distinct,histogram from dba_tab_columns where owner=user and table_name='T';
COLUMN_NAME NUM_DISTINCT HISTOGRAM
-------------------- ------------ ---------------
ID1 10000 NONE
ID2 100 FREQUENCY
NAME 1 NONE
--Id1欄位的直方圖刪除了.
--我常用的方法就是給欄位修改某個屬性.
SCOTT@test> execute dbms_stats.set_column_stats(ownname=>user,tabname=>'T',colname=> 'id2',distcnt=>NULL);
PL/SQL procedure successfully completed.
SCOTT@test> select column_name,num_distinct,histogram from dba_tab_columns where owner=user and table_name='T';
COLUMN_NAME NUM_DISTINCT HISTOGRAM
-------------------- ------------ ---------------
ID1 10000 NONE
ID2 100 NONE
NAME 1 NONE
--實際上11G的包dbms_stats提供了delete_column_stats可以刪除統計,這樣方便不少.我好像以前測試10g不行!
SCOTT@test> execute dbms_stats.gather_table_stats(user,'t',cascade=>true,method_opt=>'for all columns size 1,for columns id1 size 254 ,for columns id2 size 254');
PL/SQL procedure successfully completed.
SCOTT@test> exec dbms_stats.delete_column_stats(ownname=>user, tabname=>'T', colname=>'ID1', col_stat_type=> 'HISTOGRAM');
PL/SQL procedure successfully completed.
SCOTT@test> select column_name,num_distinct,histogram from dba_tab_columns where owner=user and table_name='T';
COLUMN_NAME NUM_DISTINCT HISTOGRAM
-------------------- ------------ ---------------
ID1 10000 NONE
ID2 100 FREQUENCY
NAME 1 NONE
--如果執行如下,該欄位的統計資訊一起刪除.
SCOTT@test> execute dbms_stats.delete_column_stats(ownname=>user,tabname=>'t',colname=>'id2');
PL/SQL procedure successfully completed.
SCOTT@test> select column_name,num_distinct,histogram from dba_tab_columns where owner=user and table_name='T';
COLUMN_NAME NUM_DISTINCT HISTOGRAM
-------------------- ------------ ---------------
ID1 10000 NONE
ID2 NONE
NAME 1 NONE
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-1153951/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- elasticsearch 之 histogram 直方圖聚合ElasticsearchHistogram直方圖
- oracle直方圖histogram小記(一)Oracle直方圖Histogram
- 轉貼oracle直方圖histogram(二)Oracle直方圖Histogram
- 11G,可以只刪除直方圖資訊直方圖
- [轉] oracle統計資訊(statistics)和直方圖(histogram)Oracle直方圖Histogram
- [20120905]刪除直方圖.txt直方圖
- 5種方法教你用Python玩轉histogram直方圖PythonHistogram直方圖
- oracle delete 分批刪除Oracledelete
- LARGE DELETE快速刪除delete
- 直方圖直方圖
- 收集直方圖及檢視直方圖資訊直方圖
- 直方圖(histograms)直方圖Histogram
- 7.3 直方圖直方圖
- oracle 直方圖Oracle直方圖
- Elasticsearch增刪改查 之 —— Delete刪除Elasticsearchdelete
- HC(Histogram-based Contrast) 基於直方圖對比度的顯著性HistogramAST直方圖
- 直方圖均衡化直方圖
- 04:垂直直方圖直方圖
- oracle直方圖使用Oracle直方圖
- 直方圖學習直方圖
- Oracle直方圖解析Oracle直方圖圖解
- [zt] Histograms - 直方圖Histogram直方圖
- dba_histograms等高直方圖和等頻直方圖的理解Histogram直方圖
- delete和truncate刪除的區別delete
- delete_partition.pl 刪除分割槽delete
- [20170615]直方圖-高度直方圖(11g).txt直方圖
- 直方圖中最大矩形直方圖
- Oracle直方圖詳解Oracle直方圖
- 【效能優化】直方圖優化直方圖
- 找回Oracle中Delete刪除的記錄Oracledelete
- 主外來鍵關聯刪除(on delete set null和on delete cascade)deleteNull
- [Python影象處理] 十一.灰度直方圖概念及OpenCV繪製直方圖Python直方圖OpenCV
- OpenCV計算機視覺學習(9)——影像直方圖 & 直方圖均衡化OpenCV計算機視覺直方圖
- halcon-直方圖均衡直方圖
- python如何畫直方圖Python直方圖
- oracle直方圖筆記-轉Oracle直方圖筆記
- 使用直方圖注意事項直方圖
- (轉)Oracle直方圖詳解Oracle直方圖