Freeing up space in SQL Server

你说的曾经没有我的故事 提交于 2019-12-25 03:27:49

问题


I wonder if anyone can point me in the right direction with this please.

I have a number of tables in a SQL Server database and I have used a script to analyze the space that's being used by each table.

The script can be found here if anyone's interested: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=61762

My table sizes only account for about a third of the size of the database, so my question is what is using the rest of space and how can I reduce the overall database size?

Many thanks for any pointers.


回答1:


Do you need to reclaim space because you have disk space problems? If not, leave it.

You are almost certain to cause issues by shrinking database and/or files:

  • http://blogs.msdn.com/b/sqlserverstorageengine/archive/2006/06/13/629059.aspx
  • http://technet.microsoft.com/en-us/magazine/ff808322.aspx
  • http://www.sqlskills.com/blogs/paul/post/Why-you-should-not-shrink-your-data-files.aspx
  • http://www.sqlskills.com/BLOGS/PAUL/post/A-SQL-Server-DBA-myth-a-day-%28930%29-data-file-shrink-does-not-affect-performance.aspx

Quoting from the last one:

Myth #9: Data file shrink does not affect performance.

Hahahahahahahahahahahahahahaha! <snort>

<wipes tears from eyes, attempts to focus on laptop screen, cleans drool from keyboard> 

Generally the database needs to be this size if it is this size based on previous auotgrows.

For example, you need free space of approximately 1.2 times your biggest table when indexes are being rebuilt. If one table is 25% of your data then this table consumes 55% during index rebuilds.

So, don't do it unless you have a severe need...




回答2:


Assuming that this is SQL Server specific,

DBCC SHRINKDATABASE

http://msdn.microsoft.com/en-us/library/aa258287%28v=sql.80%29.aspx



来源:https://stackoverflow.com/questions/6149605/freeing-up-space-in-sql-server

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!