• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
PowerCoder
博客园    首页    新随笔    联系   管理    订阅  订阅

Shrinking a SQL Server database not working(转载)

问


 

I'm not a DBA but I need to shrink a DB, I tried using the SSMS interface to shrink and it didn't work.
The stats are as follows:

  • Size: 235,013.00 MB
  • Space Available: 65,587.59 MB

I have also tried the DBCC SHRINKDATABASE ... TRUNCATEONLY command and didn't change anything either.
How can I shrink this DB (free up the unused space to the OS) without losing data?

 

 

答1


 

By the way also check the initial size. If your initial size is 235,013 MB then you need to reduce your initial size first.
Secondly, shrinking is one of the worst things your could do to a data file. If you shrink a tlog file its okay, because tlogs dont use the data page structure. If you shrink your database data file, you can make a perfectly de-fragmented database into a perfectly fragmented database. It will mess the performance beyond recognition. Why do you want to shrink by the way? The db is 200 something GB and has 60 something free.... that's like around 30% free. Don't you think in the matter of some time, that space can be utilized?
If you still need to shrink the db, you can create a file group and move the data to that file group and delete the current file group or in case of primary file group you can reduce the size to the bare minimum.

 

 

答2


 

  1. In SSMS try using Right Click on DB->Tasks->Shrink->Files to see how much space is used by data and transaction log files.
  2. It's likely that the Recovery Model for your DB is set to FULL in which case you'll not be able to shrink the transaction log unless you do a full db backup. If it's not a concern, just change the Recovery Model to Simple and try to shrink the transaction log and data files again.

 

 

原文链接

 

posted @ 2020-03-03 20:46  PowerCoder  阅读(232)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3