if exists ( select *
from dbo.sysobjects
where id = object_id(N‘[dbo].[TableSpace]‘)
and objectproperty(id, N‘IsUserTable‘) = 1 )
drop table [dbo].[TableSpace]
go
create table TableSpace
(
TableName varchar(20) ,
RowsCount char(11) ,
Reserved varchar(18) ,
Data varchar(18) ,
Index_size varchar(18) ,
Unused varchar(18)
)
go
declare @sql varchar(500)
declare @TableName varchar(20)
declare mCursor cursor
for
select name from sysobjects where xtype=‘U‘
open mCursor
fetch NEXT from mCursor into @TableName
while @@fetch_status = 0
begin
set @sql = ‘insert into TableSpace ‘
set @sql = @sql + ‘ exec sp_spaceused ‘‘‘ + @TableName + ‘‘‘ ‘
exec (@sql)
fetch NEXT from mCursor into @TableName
end
close mCursor
deallocate mCursor
go
--显示结果
select TableName,RowsCount from TableSpace
查询数据库中所有表的记录数和大小
时间: 2024-10-12 09:26:48
查询数据库中所有表的记录数和大小的相关文章
查询数据库中所有表的记录数,所占空间,索引使用空间
常用 --查询数据库中所有表的记录数,所占空间,索引使用空间 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
Oracle查询数据库中所有表的记录数
首先建立一个计算函数>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>create or
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;
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查看数据库中所有表的行数,并进行排序
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
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
SQLSERVER 数据库查看各表的记录数
select a.name as 表名,max(b.rows) as 记录条数 from sysobjects a ,sysindexes b where a.id=b.id and a.xtype='u' group by a.name order by max(b.rows) desc select SUM(记录条数) as 总记录数 from( select top 10000 a.name as 表名,max(b.rows)