数据库各个表的占有量

查看数据库各个表的行数,占有空间

select a.name,b.rows ,OBJECT_NAME(b.id) tablename ,8*b.reserved/1024 reserved,
RTRIM(8*b.dpages)/1024 as 'used(M)'
,8*(b.reserved-b.dpages)/1024 unused
,8*b.dpages/1024-rows/1024*b.minlen/1024 free
from sys.sysobjects as a
inner join sys.sysindexes as b on a.id=b.id where xtype='U' and b.indid in(0,1)
order by b.rows desc
1
2
3
4
5
6
7
8
9
10
11
--查询数据库中所有的数据库名
select * from sys.sysdatabases
  
--查询某个数据库中所有的表名
select name  from sys.sysobjects where xtype='U' 
--统计整个数据库的用户表总数
select count(1) from sys.sysobjects where xtype='U' 
--统计整个数数据库用户表的数据行数
select a.name,b.rows from sys.sysobjects as a
inner join sys.sysindexes as b on a.id=b.id where a.xtype='U'  and b.indid in(0,1)
order by b.rows  desc

  

 

posted @   密蒙  阅读(10)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
点击右上角即可分享
微信分享提示