简体   繁体   English

分配给SQL Server中表的未使用空间

[英]Unused Space allocated to table in SQL server

I have a table in my Database which has unused space of about 55GB. 我的数据库中有一个表,其中有约55GB的未使用空间。 How do I reduce this unused space? 如何减少未使用的空间?

Steps that I have tried: 我尝试过的步骤:

  1. I have rebuilt the Indexes, this helped me a lot this reduced the unused space from 110GB to 55GB. 我已经重建了索引,这对我帮助很大,这将未使用的空间从110GB减少到了55GB。
  2. By running DBCC SHOWCONTIG I found that my table's average page density is 99% (which is in a way good,but it did not help me to reduce the unused space) 通过运行DBCC SHOWCONTIG,我发现表的平均页面密度为99%(这在某种程度上不错,但是并没有帮助我减少未使用的空间)
  3. I have changed the fill factor and rebuild the index again (this time rebuilding the index after changing fill factor to 100 did not reflect any desired outcome) 我已经更改了填充因子并再次重建索引(这次将填充因子更改为100后重建索引没有反映任何期望的结果)
  4. I tried DBCC CLEANTABLE (DBNAME,"Tablename"), I could not reduce the unused space 我尝试了DBCC CLEANTABLE(DBNAME,“表名”),但无法减少未使用的空间
  5. I have not tried shrinking of DB, I want to reduce the unused space without shrinking the DB. 我没有尝试收缩数据库,我想在不收缩数据库的情况下减少未使用的空间。

Current output: 电流输出:

CurrentOutput

Desired Output: I want to reduce the Total space so that the Unused space is reduced. 所需的输出:我想减少总空间,以便减少未使用的空间。

Create a new table and then export the data to this new table. 创建一个新表,然后将数据导出到该新表。

SELECT * INTO newtable FROM table -- or copy wizard (by SSMS)

And then, drop the old table, but make you sure that the all data was transferred successfully. 然后,删除旧表,但要确保所有数据都已成功传输。

解:

ALTER INDEX ALL ON MyTable REBUILD WITH (FILLFACTOR = 100);

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

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