国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > Oracle > 正文

Oracle 統計用戶下表的數據量實現腳本

2020-07-26 14:04:05
字體:
來源:轉載
供稿:網友

要想統計用戶下所有表的數據量,可以查看user_tables,此表里面是統計信息,當然這個可能不太準,要想非常精確,需要直接count表。下面的腳本有異常不中斷,可以重復執行的特點。

create table bk_count_tables( owner VARCHAR2(30), table_name VARCHAR2(30), part_col varchar2(100),--分區字段 row_s number, gather_time date);create index ind_bct_own_table on bk_count_tables(owner,table_name);set serveroutput ondeclarecursor 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;/

總結

以上所述是小編給大家介紹的Oracle 統計用戶下表的數據量實現腳本,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對武林網網站的支持!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 莱州市| 炉霍县| 容城县| 永登县| 丹东市| 陈巴尔虎旗| 枣庄市| 安徽省| 恭城| 宜良县| 清苑县| 时尚| 虹口区| 红河县| 西乡县| 仁寿县| 白城市| 开封市| 潍坊市| 西吉县| 普安县| 依兰县| 新干县| 吉首市| 通州区| 建平县| 广宁县| 侯马市| 睢宁县| 南漳县| 乌审旗| 扎兰屯市| 新野县| 交口县| 通江县| 新源县| 武夷山市| 浦城县| 巨鹿县| 茂名市| 泗阳县|