国产探花免费观看_亚洲丰满少妇自慰呻吟_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教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 阿城市| 博野县| 丰台区| 紫阳县| 安国市| 南木林县| 中山市| 明光市| 河间市| 和顺县| 钦州市| 女性| 新平| 杨浦区| 永春县| 全南县| 无棣县| 视频| 连州市| 开鲁县| 栾城县| 仪陇县| 三都| 宜丰县| 黑龙江省| 太康县| 广河县| 衡阳县| 永定县| 马山县| 阳新县| 安阳县| 南通市| 通河县| 田阳县| 卓资县| 含山县| 上虞市| 益阳市| 沂源县| 宣化县|