您的位置:首页 > 数据库 > Oracle

oracle中所有表记录数统计

2009-03-29 17:43 357 查看
http://space.itpub.net/7104/viewspace-133950

 

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;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  oracle table c insert system