开发者

SQL server cleaning up databases, transaction logs?

开发者_如何学JAVA

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.


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.


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

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


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

    • DBCC SHRINKDATABASE
    • DBCC SHRINKFILE

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜