SQL Server 清理数据库、事务日志?

发布于 2024-10-21 06:42:36 字数 172 浏览 5 评论 0原文

我有一个 SQL Server 2005 数据库,我要从中删除几个大表到存档数据库。原始数据库应该大幅缩小。

为了创建存档数据库,我将恢复原始数据库的副本,并从中删除当前的表。

这是最好的方法吗?我应该如何处理原木/收缩以确保最终尺寸尽可能小?存档数据库可能会增长一点,但原始数据库会继续正常增长。

I have a SQL Server 2005 database from which I'm removing several large tables to an archive database. The original database should shrink considerably.

To make the archive database, I was going to restore a copy of the original and just remove the current tables from that.

Is this the best way to go about it? What should I do with logs/shrinking to make sure the final sizes are as small as possible? The archive database may grow a little, but the original continues its normal growth.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

辞慾 2024-10-28 06:42:36

这似乎是一个不错的方法。将恢复模式设置为简单,然后截断并收缩日志文件。这将使其尽可能小。

请参阅此处了解执行此操作的好方法。

注意:这假设您不希望或不需要将存档数据库恢复到特定时间点。原因是简单恢复模型不会将事务保存在事务日志中。因此,当您的存档数据库发生“一点点”变化(正如您所说)时,它不会将事务保存到日志中。

That seems like an ok way to do it. Set the recovery model to simple, then truncate and shrink the log files. This will make it as small as possible.

See here for a good way to do it.

Note: This assumes you don't want or need to recover the archive database back to specific points in time. The reason being that Simple recovery model does not save the transactions in a transaction log. So as your archive database changes "a little" (as you said), it won't save the transactions to a log.

哑剧 2024-10-28 06:42:36

我使用这个脚本,这在开发中非常有用。

BACKUP log [CustomerServiceSystem] with truncate_only
go
DBCC SHRINKDATABASE ([CustomerServiceSystem], 10, TRUNCATEONLY)
go

I use this script and this is very useful in developing.

BACKUP log [CustomerServiceSystem] with truncate_only
go
DBCC SHRINKDATABASE ([CustomerServiceSystem], 10, TRUNCATEONLY)
go
痴意少年 2024-10-28 06:42:36
  1. 重新设计数据库
  2. 尝试以下 SQL 命令之一:

或者右键单击 Sql Server Management Studio 对象资源管理器的数据库并选择任务 -收缩。

  1. Redesign the db
  2. Try one of these sql commands:

Or right click into Sql Server Management Studio Object Explorer's database and select Tasks-Shrink.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文