本文介绍了SQL Azure表大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在mssql2005中,当我想以MB为单位获取表的大小时,我使用EXEC sp_spaceused'table'.

In mssql2005 when I want to get size of table in MBs, I use EXEC sp_spaceused 'table'.

是否可以使用某些查询或API获取SQL Azure中特定表使用的空间?

Is there any way to get space used by particular table in SQL Azure using some query or API?

推荐答案

来自Ryan Dunn http://dunnry.com/blog/CalculatingTheSizeOfYourSQLAzureDatabase.aspx

From Ryan Dunnhttp://dunnry.com/blog/CalculatingTheSizeOfYourSQLAzureDatabase.aspx

select    
      sum(reserved_page_count) * 8.0 / 1024 [SizeInMB]
from    
      sys.dm_db_partition_stats

GO

select    
      sys.objects.name, sum(reserved_page_count) * 8.0 / 1024 [SizeInMB]
from    
      sys.dm_db_partition_stats, sys.objects
where    
      sys.dm_db_partition_stats.object_id = sys.objects.object_id

group by sys.objects.name
order by sum(reserved_page_count) DESC

第一个将为您提供数据库大小(以MB为单位),第二个将执行相同的操作,但将其按数据库中每个对象的大小从小到大的顺序列出.

The first one will give you the size of your database in MB and the second one will do the same, but break it out for each object in your database ordered by largest to smallest.

这篇关于SQL Azure表大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 23:25