网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

怎么在Oracle中对用户中表的数据量进行统计

怎么在Oracle中对用户中表的数据量进行统计?相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。

成都创新互联公司2013年开创至今,是专业互联网技术服务公司,拥有项目做网站、成都做网站网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元新华做网站,已为上家服务,为新华各地企业和个人服务,联系电话:18980820575

要想统计用户下所有表的数据量,可以查看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 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;
/

看完上述内容,你们掌握怎么在Oracle中对用户中表的数据量进行统计的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注创新互联行业资讯频道,感谢各位的阅读!


本文题目:怎么在Oracle中对用户中表的数据量进行统计
本文链接:http://bjjierui.cn/article/jheecp.html

其他资讯