如何在SQL Azure中找到最大数据库空间和使用的数据库空间? [英] How do I find the maximum database space and the used database space in SQL Azure?

查看:321
本文介绍了如何在SQL Azure中找到最大数据库空间和使用的数据库空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在SQL Azure中,每个数据库都有大小限制(可调整)。为了使我的服务不突然停止,我想能够以编程方式找到当前的最大大小和当前实际使用的空间(并生成和警报一旦达到阈值)。

In SQL Azure each database has a size limitation (adjustable). In order for my service to not suddenly come to a halt I'd like to be able to programmatically find the current maximum size and current actually used space (and generate and alert once some threshold is reached).

看起来像 sp_mstablespace 可以用来解决这个问题问题,但此存储过程在SQL Azure中不可用。

Looks like sp_mstablespace can be used to solve this problem, but this stored procedure is not available in SQL Azure.

如何查找SQL Azure中当前允许的最大大小和当前实际使用的空间数据库?

How do I find the current maximum allowed size and current actually used space in a SQL Azure database?

推荐答案

您可以通过动态管理视图计算已用空间(参考页 here ):

You can calculate used space via dynamic management views (reference page here):

SELECT SUM(reserved_page_count)*8.0/1024
FROM sys.dm_db_partition_stats; 

虽然我不认为你可以检索最大尺寸,数据库到最大的大小,因为你只需要为你使用的空间开帐单。话虽如此:如果你只是在5GB以下的范围内,最好去使用Web版。如果您已经达到10 GB以上,则不应该有任何危害,最大大小设置为150 GB,然后监控消耗的大小。

While I don't think you can retrieve max size, it doesn't hurt to simply set your database to the largest size, since you're only billed for space you use. Having said that: If you're only in the sub-5GB range, it's best to go with Web edition. If you're already at 10+ GB, there shouldn't be any harm setting max size to 150GB and then monitoring consumed size.

这篇关于如何在SQL Azure中找到最大数据库空间和使用的数据库空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆