查看sql所有表占用的空间大小
2012-10-31 13:38
148 查看
声明:博客内所有技术性文章都是由作者本人工作经验的总结, 实现过程中有搜索资料为参考的绝不涉嫌抄袭,均为个人习惯的总结。今天需要操作一下网站后台,添加一些图片,发现100M的数据库空间满了,所以想知道所有表占用空间的大小,以下为脚本内容:
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
drop table #tblspace
这个方法是我从网上众多方法里发掘出来的,经过试验证明完全可以达到理想的效果,以下为效果图
结束
恭喜你成功看到了sql数据库每个表占用硬盘空间的大小。
交流QQ444048361
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
drop table #tblspace
这个方法是我从网上众多方法里发掘出来的,经过试验证明完全可以达到理想的效果,以下为效果图
结束
恭喜你成功看到了sql数据库每个表占用硬盘空间的大小。
交流QQ444048361
相关文章推荐
- 快速查看SQL各表的数据量以及占用空间大小
- MySQL中查询所有数据库占用磁盘空间大小和单个库中所有表的大小的sql语句
- SQL Server 查看数据表占用空间大小的SQL语句
- 查看Sql Server所有表占用的空间大小
- 常用SQL:看全部表的空间大小|tempdb使用情况|清空日志|查看日志|查看数据库表|禁用所有约束|系统表|系统视图
- 查看所有用户在oracle数据库占用空间大小
- 查看mysql中database占用磁盘空间的大小SQL语句【测试通过】
- MySQL查看数据库、表的占用空间大小以及某个库中所有表的引擎类型
- sql查询数据库中所有表的记录条数,以及占用磁盘空间大小。
- Db2查看未提交的事务开始时间、占用日志空间大小、应用IP地址、执行的SQL语句等信息
- 查看mysql中database占用磁盘空间的大小SQL语句
- MySQL中查询所有数据库占用磁盘空间大小和单个库中所有表的大小的sql语句
- SQL Server查看所有表大小、表行数和占用空间信息
- MySQL中查询所有数据库占用磁盘空间大小和单个库中所有表的大小的sql语句
- MySQL查看表占用空间大小(转)
- linux下使用 du查看某个文件或目录占用磁盘空间的大小
- Hive下查看表占用空间大小的方法
- Linux命令之查看文件占用空间大小-du,df
- MySQL查看表占用空间大小
- MAC 命令行 查看硬盘和文件夹大小(占用空间)