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