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

首頁 > 數據庫 > Oracle > 正文

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

2024-08-29 14:00:31
字體:
來源:轉載
供稿:網友

要想統計用戶下所有表的數據量,可以查看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 統計用戶下表的數據量實現腳本,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對VeVb武林網網站的支持!


注:相關教程知識閱讀請移步到oracle教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 江永县| 柘荣县| 临颍县| 大英县| 安溪县| 白朗县| 安达市| 都昌县| 同江市| 常德市| 兰州市| 嘉兴市| 四川省| 栾川县| 溆浦县| 微山县| 满洲里市| 高唐县| 大埔县| 胶州市| 临西县| 棋牌| 库尔勒市| 石棉县| 宁波市| 万源市| 涿鹿县| 沂源县| 亳州市| 平乐县| 年辖:市辖区| 尚义县| 加查县| 紫阳县| 中卫市| 白银市| 洮南市| 常德市| 遂平县| 牟定县| 临漳县|