sql 语句列出数据库中的表的记录数、占用空间大小等
2012-02-15 22:08
441 查看
set nocount on
declare @db varchar(20)
set @db = db_name()
dbcc updateusage(@db) with no_infomsgs
go
create table #tblspace
(
数据表名称 varchar(50) null,
记录笔数 int null,
保留空间 varchar(15) null,
数据使用空间 varchar(15) null,
索引使用空间 varchar(15) null,
未使用空间 varchar(15) null,
)
declare @tblname varchar(50)
declare curtbls cursor for
select table_name from information_schema.tables
where table_type = 'base table'
open curtbls
Fetch next from curtbls into @tblname
while @@fetch_status = 0
begin
insert #tblspace exec sp_spaceused @tblname
fetch next from curtbls into @tblname
end
close curtbls
deallocate curtbls
select * from #tblspace
--order by convert(int,left(保留空间,len(保留空间)-2)) desc
order by 记录笔数 desc
drop table #tblspace
declare @db varchar(20)
set @db = db_name()
dbcc updateusage(@db) with no_infomsgs
go
create table #tblspace
(
数据表名称 varchar(50) null,
记录笔数 int null,
保留空间 varchar(15) null,
数据使用空间 varchar(15) null,
索引使用空间 varchar(15) null,
未使用空间 varchar(15) null,
)
declare @tblname varchar(50)
declare curtbls cursor for
select table_name from information_schema.tables
where table_type = 'base table'
open curtbls
Fetch next from curtbls into @tblname
while @@fetch_status = 0
begin
insert #tblspace exec sp_spaceused @tblname
fetch next from curtbls into @tblname
end
close curtbls
deallocate curtbls
select * from #tblspace
--order by convert(int,left(保留空间,len(保留空间)-2)) desc
order by 记录笔数 desc
drop table #tblspace
相关文章推荐
- MySQL中查询所有数据库占用磁盘空间大小和单个库中所有表的大小的sql语句
- sql查询数据库中所有表的记录条数,以及占用磁盘空间大小。
- MySQL中查询所有数据库占用磁盘空间大小和单个库中所有表的大小的sql语句
- MySQL中查询所有数据库占用磁盘空间大小和单个库中所有表的大小的sql语句
- 查询SQLSERVER某个表所占用空间大小的SQL语句
- 查看mysql中database占用磁盘空间的大小SQL语句
- 一行sql返回mysql中各数据库占用空间大小
- 列出当前数据库中所有表的大小的SQL语句
- Oracle 查看表空间的大小及使用情况sql语句(oracle数据库维护精品)
- sql查询数据库中表占用空间大小
- SQL语句查询数据库表占用和记录数
- 如何用 SQL 语句获取某个 ACCESS 表占用的磁盘空间大小?
- SQL Server 查看数据表占用空间大小的SQL语句
- Db2查看未提交的事务开始时间、占用日志空间大小、应用IP地址、执行的SQL语句等信息
- SQL - SQL Server 列出每个表所占用空间大小
- sql语句在sql server中查询每个表的记录数,占用的空间,索引占用的空间等
- 查看mysql中database占用磁盘空间的大小SQL语句【测试通过】
- MySQL查看数据库、表的占用空间大小以及某个库中所有表的引擎类型
- 查看某个表在数据库中占用空间的大小
- MySQL查看数据库、表的占用空间大小