简体   繁体   English

缩小数据库SQL Server 2008

[英]Shrink data base SQL Server 2008

HI I have made a maintenance package in that have used shrink database task for specific database, it ran successfully, found slight increase in previous db size. 您好,我制作了一个维护包,其中使用了针对特定数据库的收缩数据库任务,它成功运行,发现以前的数据库大小略有增加。 Initial size(129 gb) after running the package(130gb). 运行程序包(130gb)后的初始大小(129 gb)。

I am expecting after shrinkning it should shrink? 我期望收缩后应该收缩吗? what might be happen? 会发生什么? am sure package scheduled to run and check the history found run successfully. 确保程序包计划运行并检查发现的历史记录是否成功运行。

Any help/ please advise any special care required, Thanks in advance. 任何帮助/请告知需要的任何特殊护理,谢谢。

Do not shrink the database during maintenance. 维护期间不要收缩数据库。 There is probably no other more damaging action you can do. 您可能没有其他破坏性的动作可以做。 Read more at Auto-shrink – turn it OFF . 在“ 自动收缩”中了解更多信息-将其关闭 IF a database has grown to a certain size, then it will likely grow back if you shrink it. 如果数据库已增长到一定大小,则如果将其收缩,它很可能会重新增长。 Shrinking the database is tremendously damaging to the index fragmentation and will slow down your reporting and analytic workloads. 缩小数据库会极大地破坏索引碎片,并且会减慢报告和分析工作量。 Once shrink, when the database will grow back during normal operations the auto-growth events will interrupt and freeze the database during the growth. 一旦收缩,当数据库将在正常操作期间重新增长时,自动增长事件将在增长期间中断并冻结数据库。

There is one thing to shrink a database that had got out of control due to some rogue action that increased it. 收缩由于某些流氓行为而失去控制的数据库是一回事。 But to have the shrink in maintenance task means you will constantly do it on a scheduled interval, and this is very bad . 但是要减少维护任务意味着您将按计划的时间间隔不断执行它,这非常糟糕

There are a couple of things you can do the check on this. 您可以做几件事来进行检查。 In SQL Server Management Studio (SSMS), Object Explorer, right-click on the database name and select Properties. 在SQL Server Management Studio(SSMS)的“对象资源管理器”中,右键单击数据库名称,然后选择“属性”。 On the General tab you'll find the Space Available value. 在常规选项卡上,您将找到可用空间值。 Is there any available space? 是否有可用空间?

Note that the space available includes space in the transaction log file. 请注意,可用空间包括事务日志文件中的空间。 You need that space, so you don't want to shrink the database too much. 您需要该空间,所以您不想缩小太多数据库。

Also, keep in mind that you're database is probably in full recovery mode. 另外,请记住,您的数据库可能处于完全恢复模式。 what this means is that, as data is being inserted, updated, and deleted in the database, sql server logs it in the database log. 这意味着,当在数据库中插入,更新和删除数据时,sql server会将其记录在数据库日志中。 This log can become quite large on a busy database. 在繁忙的数据库上,此日志可能会变得很大。 You can reduce the size of the log by performing full backups. 您可以通过执行完全备份来减少日志的大小。 Remember, the point of the log is so that you can do log backups and do point in time restores. 请记住,日志的重点是可以进行日志备份和时间点还原。 If you're not doing this, or don't need to do this, you might consider having the database turned to simple recovery mode. 如果您不执行此操作,或者不需要执行此操作,则可以考虑将数据库设置为简单恢复模式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM