濮阳杆衣贸易有限公司

主頁 > 知識庫 > Oracle 統(tǒng)計(jì)用戶下表的數(shù)據(jù)量實(shí)現(xiàn)腳本

Oracle 統(tǒng)計(jì)用戶下表的數(shù)據(jù)量實(shí)現(xiàn)腳本

熱門標(biāo)簽:電話機(jī)器人那種好 地圖標(biāo)注的坐標(biāo)點(diǎn) 上海網(wǎng)絡(luò)外呼系統(tǒng) 區(qū)域地圖標(biāo)注怎么設(shè)置 外呼系統(tǒng)好點(diǎn)子 南通電銷外呼系統(tǒng)哪家強(qiáng) 理財(cái)產(chǎn)品電銷機(jī)器人 百度地圖標(biāo)注飯店位置怎么 百度地圖標(biāo)注注解

要想統(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;
/

總結(jié)

以上所述是小編給大家介紹的Oracle 統(tǒng)計(jì)用戶下表的數(shù)據(jù)量實(shí)現(xiàn)腳本,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時(shí)回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!

您可能感興趣的文章:
  • PDO取Oracle lob大字段,當(dāng)數(shù)據(jù)量太大無法取出的問題的解決辦法
  • Oracle 12c新特性之如何檢測有用的多列統(tǒng)計(jì)信息詳解
  • Oracle 11g收集多列統(tǒng)計(jì)信息詳解
  • Oracle Translate 統(tǒng)計(jì)字符出現(xiàn)的次數(shù)示例代碼
  • Oracle數(shù)據(jù)庫按時(shí)間進(jìn)行分組統(tǒng)計(jì)數(shù)據(jù)的方法
  • oracle表空間中空表統(tǒng)計(jì)方法示例介紹
  • oracle數(shù)據(jù)庫下統(tǒng)計(jì)專營店的男女?dāng)?shù)量的語句

標(biāo)簽:中衛(wèi) 昭通 寧波 紹興 百色 自貢 遼源 海東

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Oracle 統(tǒng)計(jì)用戶下表的數(shù)據(jù)量實(shí)現(xiàn)腳本》,本文關(guān)鍵詞  Oracle,統(tǒng)計(jì),用戶,下表,的,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《Oracle 統(tǒng)計(jì)用戶下表的數(shù)據(jù)量實(shí)現(xiàn)腳本》相關(guān)的同類信息!
  • 本頁收集關(guān)于Oracle 統(tǒng)計(jì)用戶下表的數(shù)據(jù)量實(shí)現(xiàn)腳本的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    荣成市| 青州市| 长兴县| 吴川市| 鸡泽县| 沿河| 开远市| 卫辉市| 启东市| 隆林| 咸宁市| 廊坊市| 衡阳县| 贡山| 闽侯县| 扶绥县| 镇原县| 微山县| 镇平县| 渭源县| 嘉峪关市| 资溪县| 德州市| 荔浦县| 海南省| 荥经县| 商丘市| 开化县| 赞皇县| 毕节市| 民县| 白山市| 景洪市| 德庆县| 建德市| 时尚| 赣榆县| 明光市| 德清县| 政和县| 卢氏县|