gpt4 book ai didi

sql-server - Sql Server LDF 文件占用太大空间

转载 作者:行者123 更新时间:2023-12-03 15:59:25 26 4
gpt4 key购买 nike

为什么我的数据库日志文件占用了大量空间?它几乎占用30GB我的硬盘。即使在删除 1,000,000 之后记录,它没有释放任何空间。
所以,1.为什么日志文件占用这么多空间( 30gb )? 2.我怎样才能释放空间?

最佳答案

1.Why is the log file taking this much space (30gb)?


  • 或者因为你的恢复不简单而 ldf 最终增长到这样的大小
  • 或者因为有一个大型的一次性 DML 操作
  • 或者由于其他原因,正如@sepupic 在另一个答案中指出的那样

  • 2.how can I free up the space?


  • 如果恢复不是简单的:
  • 首先备份事务日志文件
  • 执行收缩,如 DBCC SHRINKFILE(2,256)
  • 如果恢复很简单:
  • 只需将其缩小到所需大小,例如 DBCC SHRINKFILE(2,256)

  • 如果数据库日志仍然没有减少到目标大小,则使用@sepupic 的代码片段检查确切原因

    一些成员仍然提供和建议物理删除 LDF 文件。

    我强烈建议不要这样做。卓越相关 post亚伦伯特兰:

    Some things you don't want to do:

    Detach the database, delete the log file, and re-attach. I can't emphasize how dangerous this can be. Your database may not come back up, it may come up as suspect, you may have to revert to a backup (if you have one), etc. etc.

    关于sql-server - Sql Server LDF 文件占用太大空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54944677/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com