查看Oracle表的记录数

方法一:

SELECT t.table_name, t.num_rows FROM sys.dba_tables t
       where owner='DATA' and num_rows is not null order by num_rows desc
--- Oracle 10g ,owner要大写

 

方法二:

查看记录行数,表的创建、修改时间

 SELECT a.owner, a.table_name,a.num_rows, created, last_ddl_time
  FROM sys.dba_tables a, SYS.dba_objects b
WHERE
--a.tablespace_name = 'USERS'
--   AND a.owner = b.owner
a.owner='Cweb'
   AND a.table_name = b.object_name
   AND object_type = 'TABLE' order by  num_rows desc

 

 方法三:

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;

 

posted @ 2009-12-30 13:55  观我生,君子无咎  阅读(1585)  评论(0)    收藏  举报