独孤狼群
===========================================================
oracle中所有表记录数统计
===========================================================
oracle中所有表记录数统计

create table A
(
USERNAME VARCHAR2(20),
TABLENAME VARCHAR2(50),
JS VARCHAR2(10)
)

create or replace procedure p_getcount
as
miCount INTEGER;
t_owner varchar2(40);
t_table varchar2(40);
BEGIN
FOR c_tab IN (SELECT owner,table_name FROM dba_tables where owner not in ('SYS','SYSTEM','CTXSYS','PERFSTAT','WMSYS','EXFSYS','SYSMAN')) LOOP
--dbms_output.put_line('select count(*) from ' || c_tab.owner||'.'||c_tab.table_name || '');
--dbms_output.put_line( c_tab.owner||'.'||c_tab.table_name);
t_owner := c_tab.owner;
t_table := c_tab.table_name;
EXECUTE IMMEDIATE 'select count(*) from ' || c_tab.owner||'.'||'"'||c_tab.table_name||'"' || '' into miCount;
--dbms_output.put_line(rpad(c_tab.table_name,30,'.') || lpad(miCount,10,'.'));
INSERT INTO A VALUES (C_TAB.OWNER,C_TAB.TABLE_NAME,miCount);


END LOOP;

EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line( t_owner||'.'||t_table);
RAISE;
commit;
end;

liuxh6 发表于:2007.06.28 14:24 ::分类: ( pl/sql ) ::阅读:(611次) :: 评论 (0)

发表评论
标题

在此添加评论
表情符号: smile laughing tongue angry crying sad wassat wink

称呼

邮箱地址(可选)

个人主页(可选)




切换风格
新闻聚合
博客日历
文章归档...
最新发表...
博客统计...
Blog信息
网站链接...