Home > Database > Mysql Tutorial > body text

通过备份记录获取数据库的增长情况

WBOY
Release: 2016-06-07 17:58:26
Original
906 people have browsed it

通过备份记录获取数据库的增长情况

通常大家想知道数据库是否增长了,增长了多少。大家可能想到用数据库的各个历史时期的大小来比较就可以了。
但怎么能得到这些历史的大小数据呢?好像没有很好的办法
我今天讲的方法是通过查看备份记录的方式来了解数据库的增长情况。
首先,我们应该对数据库经常备份,这个可以做过Job实现。
数据库的备份记录保存在msdb数据库的backupset表中,通过查看备份记录,我们可以得到数据库增长的粗略估计。

查看的脚本如下:
代码如下:
select
BackupDate = convert(varchar(10),backup_start_date, 111)
,SizeInGigs=floor( backup_size/1024000000) --转换大小为 GB单位
from msdb..backupset
where
database_name = 'DatabaseName' --你要查看的数据库名称,请替换
and type = 'd'
order by
backup_start_date desc

输出结果大概如下:
BackupDate SizeInGigs
2009/06/22 2
2009/06/04 1
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!