码迷,mamicode.com
首页 > 数据库 > 详细

SQL查看数据库中每张表的数据量和总数据量

时间:2017-12-28 18:26:27      阅读:219      评论:0      收藏:0      [点我收藏+]

标签:name   总数   post   pos   col   dex   obj   object   nbsp   

查看所有表对应的数据量

SELECT   a.name AS 表名, MAX(b.rows) AS 记录条数
FROM      sys.sysobjects AS a INNER JOIN
                sys.sysindexes AS b ON a.id = b.id
WHERE   (a.xtype = u)
GROUP BY a.name
ORDER BY 记录条数 DESC

 

查看数据库的总数据量

SELECT   SUM(记录条数) AS 总记录数
FROM      (SELECT   TOP (10000) a.name AS 表名, MAX(b.rows) AS 记录条数
                 FROM      sys.sysobjects AS a INNER JOIN
                                 sys.sysindexes AS b ON a.id = b.id
                 WHERE   (a.xtype = u)
                 GROUP BY a.name
                 ORDER BY 记录条数 DESC) AS t1

 

SQL查看数据库中每张表的数据量和总数据量

标签:name   总数   post   pos   col   dex   obj   object   nbsp   

原文地址:https://www.cnblogs.com/ideacore/p/8136888.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!