删除行后数据库大小不变 [英] Database size after deleting rows does not change

查看:100
本文介绍了删除行后数据库大小不变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个数据库,为了减少数据库的大小,已从其中删除了特定表中的行。

I have 2 databases from which I have deleted rows in a specific table in order to decrease the size of the database.

删除后, DB.mdf 不变。

我也尝试重建索引并使用 cleantable ,但无效!

I also tried to rebuild the index and used cleantable, but to no effect!

ALTER INDEX ALL ON dbo.'Tablename' REBUILD

DBCC CLEANTABLE ('DBname', 'Tablename', 0)


推荐答案

删除数据库中的行不会减小实际数据库文件的大小。

Deleting rows in a database will not decrease the actual database file size.

删除行后需要压缩数据库。

You need to compact the database after row deletion.

看为此
运行此命令后,您将需要重建索引。缩小通常会导致索引碎片,这可能会带来巨大的性能成本。

Look for this After running this, you'll want to rebuild indexes. Shrinking typically causes index fragmentation, and that could be a significant performance cost.

我还建议缩小后重新增长文件,以便拥有一些文件。可用空间。这样,当出现新行时,它们不会触发自动增长。 Autogrowth会降低性能,并且您希望尽可能避免这种情况。

I would also recommend that after you shrink, you re-grow the files so that you have some free space. That way, when new rows come in, they don't trigger autogrowth. Autogrowth has a performance cost and is something you would like to avoid whenever possible.

这篇关于删除行后数据库大小不变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆