怎么在Oracle中對(duì)用戶中表的數(shù)據(jù)量進(jìn)行統(tǒng)計(jì)-創(chuàng)新互聯(lián)

怎么在Oracle中對(duì)用戶中表的數(shù)據(jù)量進(jìn)行統(tǒng)計(jì)?相信很多沒有經(jīng)驗(yàn)的人對(duì)此束手無策,為此本文總結(jié)了問題出現(xiàn)的原因和解決方法,通過這篇文章希望你能解決這個(gè)問題。

成都創(chuàng)新互聯(lián)專業(yè)IDC數(shù)據(jù)服務(wù)器托管提供商,專業(yè)提供成都服務(wù)器托管,服務(wù)器租用,服務(wù)器機(jī)柜租用,服務(wù)器機(jī)柜租用,成都多線服務(wù)器托管等服務(wù)器托管服務(wù)。

要想統(tǒng)計(jì)用戶下所有表的數(shù)據(jù)量,可以查看user_tables,此表里面是統(tǒng)計(jì)信息,當(dāng)然這個(gè)可能不太準(zhǔn),要想非常精確,需要直接count表。下面的腳本有異常不中斷,可以重復(fù)執(zhí)行的特點(diǎn)。

create table bk_count_tables
(
 owner VARCHAR2(30),
 table_name VARCHAR2(30),
 part_col varchar2(100),--分區(qū)字段
 row_s number,
 gather_time date
);
create index ind_bct_own_table on bk_count_tables(owner,table_name);
set serveroutput on
declare
cursor c_cursor is select s.OWNER, s.TABLE_NAME, col.column_name part_col
  from dba_tables s,
    (select owner,
        name,
        listagg(column_name, ',') within group(order by null) column_name
      from (select owner, name, column_name
          from dba_part_key_columns
         where owner in ('TEST')
          and object_type = 'TABLE'
          and name not like 'BIN$%'
         union all
         select owner, name, column_name
          from dba_subpart_key_columns
         where owner in ('TEST')
          and object_type = 'TABLE'
          and name not like 'BIN$%')
     group by owner, name) col
 where s.OWNER in ('TEST')
  and not regexp_like(table_name, '[0-9]{3,8}')
  and s.table_name not like '%BAK%'
  and s.table_name not like '%A2K%'
  and s.table_name not like 'BK%'
  and s.table_name not like 'BIN%'
  and s.OWNER = col.owner(+)
  and s.TABLE_NAME = col.name(+)
order by s.TABLE_NAME ;
c_row c_cursor%rowtype;
t_rows number;
begin
 for c_row in c_cursor loop
  begin
   execute immediate 'select count(*) from bk_count_tables where owner=:1 and TABLE_NAME=:2 and rownum=1' 
   into t_rows using c_row.OWNER,c_row.TABLE_NAME ;
   if(t_rows = 0) then 
    execute immediate 'select count(*) from "'||c_row.TABLE_NAME||'"' into t_rows;
    insert into bk_count_tables values(c_row.OWNER,c_row.TABLE_NAME,c_row.part_col,t_rows,sysdate);
    commit; 
    end if;
  EXCEPTION
   WHEN OTHERS THEN
   DBMS_OUTPUT.PUT_LINE(c_row.OWNER||'---'||c_row.TABLE_NAME);
   rollback; 
  end;
 end loop;
end;
/

看完上述內(nèi)容,你們掌握怎么在Oracle中對(duì)用戶中表的數(shù)據(jù)量進(jìn)行統(tǒng)計(jì)的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!

文章題目:怎么在Oracle中對(duì)用戶中表的數(shù)據(jù)量進(jìn)行統(tǒng)計(jì)-創(chuàng)新互聯(lián)
文章鏈接:http://bm7419.com/article8/gegop.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供虛擬主機(jī)、手機(jī)網(wǎng)站建設(shè)、關(guān)鍵詞優(yōu)化、企業(yè)建站、ChatGPT、網(wǎng)站營(yíng)銷

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站建設(shè)