Oracle查询数据库中所有表的记录数

首先建立一个计算函数
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
create or replace function count_rows(table_name in varchar2,
                              owner in varchar2 default null)
return number
authid current_user
IS
   num_rows number;
   stmt varchar2(2000);
begin
   if owner is null then
      stmt := ‘select count(*) from "‘||table_name||‘"‘;
   else
      stmt := ‘select count(*) from "‘||owner||‘"."‘||table_name||‘"‘;
   end if;
   execute immediate stmt into num_rows;
   return num_rows;
end;
然后通过计算函数进行统计
select table_name, count_rows(table_name) nrows from user_tables

时间: 2024-08-11 01:35:11

Oracle查询数据库中所有表的记录数的相关文章

查询数据库中所有表的记录数,所占空间,索引使用空间

常用 --查询数据库中所有表的记录数,所占空间,索引使用空间 exec sp_MSForEachTable @precommand=N'create table ##(表名 sysname,记录数 int,保留空间 Nvarchar(20),使用空间 varchar(20),索引使用空间 varchar(20),未用空间 varchar(20))', @command1=N'insert ## exec sp_spaceused ''?''', @postcommand=N'select * f

查询数据库中所有表的记录数和大小

if exists ( select  *            from    dbo.sysobjects            where   id = object_id(N'[dbo].[TableSpace]')                    and objectproperty(id, N'IsUserTable') = 1 )     drop table [dbo].[TableSpace]gocreate table TableSpace    (      Tabl

sql查询数据库中所有表的记录条数,以及占用磁盘空间大小。

1 SELECT 2 TableName = obj.name, 3 TotalRows = prt.rows, 4 [SpaceUsed(KB)] = SUM(alloc.used_pages)*8 5 FROM sys.objects obj 6 JOIN sys.indexes idx on obj.object_id = idx.object_id 7 JOIN sys.partitions prt on obj.object_id = prt.object_id 8 JOIN sys.

显示数据库中所有表的记录数

SELECT o.name, ddps.row_count FROM sys.indexes AS i INNER JOIN sys.objects AS o ON i.OBJECT_ID = o.OBJECT_ID INNER JOIN sys.dm_db_partition_stats AS ddps ON i.OBJECT_ID = ddps.OBJECT_ID AND i.index_id = ddps.index_id WHERE i.index_id < 2 AND o.is_ms_

mysql 查看数据库中所有表的记录数

use information_schema; SELECT t.table_name, t.table_rowsFROM TABLES tWHERE 1 = 1AND t.table_schema = 'mysql_database_name'-- 自己数据的名字ORDER BY t.table_rows, t.table_name;

ORACLE查询数据库的锁表情况

  查询数据库的锁表情况语句如下: SELECT p.spid,a.serial#, c.object_name,b.session_id,b.oracle_username,b.os_user_name FROM v$process p,v$session a, v$locked_object b,all_objects c WHERE p.addr=a.paddr AND a.process=b.process AND c.object_id=b.object_id 如果表因为某些情况出现死

MySql 查询数据库中所有表名

查询数据库中所有表名select table_name from information_schema.tables where table_schema='csdb' and table_type='base table'; 查询指定数据库中指定表的所有字段名column_nameselect column_name from information_schema.columns where table_schema='csdb' and table_name='users'

MySql 查询数据库中所有表

查询数据库中所有表名select table_name from information_schema.tables where table_schema='csdb' and table_type='base table'; 查询指定数据库中指定表的所有字段名column_nameselect column_name from information_schema.columns where table_schema='csdb' and table_name='users' 原文地址:htt

mysql查看数据库中所有表的行数,并进行排序

mysql查看数据库中所有表的行数,并进行排序: 进行数据库迁移或还原后,可以通过比较行数,检查数据是否正确. mysql> use information_schema; mysql> select table_name,table_rows from tables where TABLE_SCHEMA= 'kpsumi' order by table_rows desc; 原文地址:http://blog.51cto.com/9285090/2119096