begin
成都創(chuàng)新互聯(lián)公司是一家專業(yè)從事成都網(wǎng)站設(shè)計、做網(wǎng)站的網(wǎng)絡(luò)公司。作為專業(yè)的建站公司,成都創(chuàng)新互聯(lián)公司依托的技術(shù)實力、以及多年的網(wǎng)站運營經(jīng)驗,為您提供專業(yè)的成都網(wǎng)站建設(shè)、全網(wǎng)整合營銷推廣及網(wǎng)站設(shè)計開發(fā)服務(wù)!
dbms_stats.gather_table_stats( ownname='XXXX',tabname = 'XXXX' ,ESTIMATE_PERCENT=100,degree=8, CASCADE=true);
end;
參數(shù)說明:
ownname:要分析表的擁有者
tabname:要分析的表名.
partname:分區(qū)的名字,只對分區(qū)表或分區(qū)索引有用.
estimate_percent:采樣行的百分比,取值范圍[0.000001,100],null為全部分析,不采樣. 常量:DBMS_STATS.AUTO_SAMPLE_SIZE是默認(rèn)值,由oracle決定最佳取采樣值.
block_sapmple:是否用塊采樣代替行采樣.
method_opt:決定histograms信息是怎樣被統(tǒng)計的.method_opt的取值如下:
for all columns:統(tǒng)計所有列的histograms.
for all indexed columns:統(tǒng)計所有indexed列的histograms.
for all hidden columns:統(tǒng)計你看不到列的histograms
for columns SIZE | REPEAT | AUTO | SKEWONLY:統(tǒng)計指定列的histograms.N的取值范圍[1,254]; REPEAT上次統(tǒng)計過的histograms;AUTO由oracle決定N的大小;SKEWONLY multiple end-points with the same value which is what we define by "there is skew in the data
degree:決定并行度.默認(rèn)值為null.
granularity:Granularity of statistics to collect ,only pertinent if the table is partitioned.
cascace:是收集索引的信息.默認(rèn)為falase.
stattab指定要存儲統(tǒng)計信息的表,statid假如多個表的統(tǒng)計信息存儲在同一個stattab中用于進(jìn)行區(qū)分.statown存儲統(tǒng)計信息表的擁有者.以上三個參數(shù)若不指定,統(tǒng)計信息會直接更新到數(shù)據(jù)字典.
no_invalidate: Does not invalidate the dependent cursors if set to TRUE. The procedure invalidates the dependent cursors immediately if set to FALSE.
force:即使表鎖住了也收集統(tǒng)計信息.
例子:
execute dbms_stats.gather_table_stats(ownname = 'owner',tabname = 'table_name' ,estimate_percent = null ,method_opt = 'for all indexed columns' ,cascade = true);
analyze table table_name COMPUTE STATISTICS\x0d\x0a對表分析后在使用\x0d\x0aselect count(^) from table_name \x0d\x0a如果你的table_name 有主鍵 ID\x0d\x0aselect count(ID) from table_name 在統(tǒng)計的時候會用到主鍵索引
用一個過程
create or replace procedure procedure_name as
begin
insert into 統(tǒng)計表
select 字段名1,count(1) from 表 group by 字段名1
--統(tǒng)計表中的字段。(字段名1,數(shù)量)。如果有其它字段,請加入到下面select語句中。如:
/* insert into 統(tǒng)計表
select 字段名1,sysdate,'統(tǒng)計者的姓名', count(1) from 表 group by 字段名1*/
end;
可以通過district來取出字段,之后通過count計算總數(shù)量。
sql:select count(district id) from tablename;
如果id字段沒有空值的話,可以通過count統(tǒng)計字段的總數(shù)量(字段內(nèi)容可能重復(fù))。
sql:select count(id) from tablename;
本文名稱:oracle怎么統(tǒng)計分析,oracle 統(tǒng)計
鏈接地址:http://chinadenli.net/article38/hegdsp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站制作、網(wǎng)站改版、用戶體驗、電子商務(wù)、建站公司、響應(yīng)式網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)