实时 SQL Server 2005 数据库的上次修改日期
有没有办法知道实时 SQL Server 2005 数据库中最后一次写入操作发生的时间?
目前我的服务器上有 30 个(并且还在不断增加)数据库。只有其中一些可以看到日常活动(但哪些获得日常活动会随着时间的推移而变化。)我的备份空间有限,我想对所有“自上次备份以来修改的”数据库进行每日备份。
事实上,我问的是 的相反内容这个问题。我不想询问备份的上次写入日期来查看是否应该恢复它,而是想告诉实时数据库的上次写入日期来查看是否应该备份它。
由于备份在服务器本身上运行,我可以检查日志的上次修改时间,但这不是很干净,我也不确定是否完全可靠。
Is there a way to know when the last write operation has occurred in a live SQL Server 2005 database?
I currently have 30 (and growing) databases on my server. Only some of these see daily activity (but which ones get daily activity varies over time.) My backup space is limited and I'd like to do a daily backup of all "modified since last backup" databases.
In fact, I'm asking the reverse of this question. Instead of asking last write date from a backup to see if I should restore it, I want to tell last write date of a live database to see if I should back it up.
Since the backups run on the server itself, I could check the last modification time of the log, but that isn't very clean, nor I'm sure is totally reliable.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
这会有所帮助吗:
Would this help:
此博客条目包含以下信息:如何在 SQL Server 2008 和 2005 上执行此操作。
This Blog entry contains information on how to do it on SQL Server 2008 and 2005.
您可能需要重新考虑您的备份策略,也许可以将每周完整备份作为基准,然后运行 本周差异备份。当然,这一切都取决于您与恢复业务的 SLA。
You might want to rethink your backup strategy, perhaps by taking a weekly full backup as a baseline and then running differential backups during the week. Of course, this all depends on your SLA with the business for recovery.
levidos 抱歉,您得到的信息不正确。因为您没有对每个数据库的前一个进行排序,所以您实际上没有获得最后修改日期,而是获得了第一个返回的记录。
请将我的结果与你的结果进行比较。
这是我的更新。
levidos sorry but you get incorrect information. Because you are not sorting your top one per database so you really aren't getting the LAST MODIFIED DATE you're getting the first returned record.
Please compare my results to yours.
Here's my update.
上面有一些不正确的代码段。我已经修复了上面的 SQLEagle 的代码片段,现在您确实应该看到最后修改日期 - 我相信修改日期应该来自 sys.objects,而不是 sys.tables。我看到安德鲁·阿诺德评论黛比的代码片段“完全相同”。然而,Andrew 显然没有运行这两个代码段,否则他会知道 Debbie 的结果比 WaterCooler 的贡献更好,实际上提供了几乎正确的结果,但可以按如下进一步改进。
There are a number of incorrect code segments above. I have fixed SQLEagle's code snippet above and now you should indeed see the last modified dates - I believe modified date should come from sys.objects, not sys.tables. I see Andrew Arnold commented on Debbie's code snippet "being exactly the same". Andrew clearly didn't run these two code segments however or he would know Debbie's result gets a better result than WaterCooler's contribution in terms of actually providing an almost correct result, but could be further improved as per below.
这将列出服务器上的所有在线数据库以及最后修改日期
This one will list all online databases on the server and the last modified date