查询ORACLE中所有表的记录数量

  1. 1。执行
  2. create or replace function count_rows(table_name in varchar2,owner in varchar2 default null)
  3. return number authid current_user IS
  4. num_rows number;
  5. stmt varchar2(2000);
  6. begin
  7. if owner is null then
  8. stmt := 'select count(*) from "' || table_name || '"';
  9. else
  10. stmt := 'select count(*) from "' || owner || '"."' || table_name || '"';
  11. end if;
  12. execute immediate stmt
  13. into num_rows;
  14. return num_rows;
  15. end;
  16. 2.执行
  17. select table_name,count_rows(table_name) nrows
  18. from user_tables
  19. order by table_name asc

Guess you like

Origin blog.csdn.net/wangbaosongmsn/article/details/119939640