Oracle-统计数据库表数据总数量

create or replace procedure prc_table_count(p_flag out varchar2) AS
 TCOUNT   number;
 SCOUNT   number;
 COUNTSQL VARCHAR2(500);

BEGIN
  TCOUNT:= 0;
  SCOUNT:= 0;
  FOR c_row IN (
      select table_name from SYS.USER_TAB_COMMENTS t WHERE T.table_name LIKE 'ZZJG%'
) LOOP
   COUNTSQL:='select count(1) from '||C_ROW.table_name; 
   DBMS_OUTPUT.put_line(COUNTSQL);
   execute immediate COUNTSQL into TCOUNT;
   SCOUNT:=SCOUNT+TCOUNT;
  END LOOP;
  DBMS_OUTPUT.put_line(SCOUNT);
  p_flag := '1';
END prc_table_count;

 

posted @ 2017-12-26 19:07  伍叶春  阅读(6019)  评论(0编辑  收藏  举报