且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

永久删除表时回收 SQL Server 2005 数据库中的空间

更新时间:2023-01-31 13:30:39

DBCC Shrinkdatabase(0) --  Currently selected database

DBCC Shrinkdatabase(<databasename>) --  Named database

然而,缩小文件可能会使您的表格碎片化,尤其是较大的表格,因为表格的内容在文件中移动,因此一旦缩小,***对表格进行碎片整理.当然,这会使您的文件再次增长,但可能不会像删除旧表之前那样大.(呃,假设删除的表包含大量数据......)

However, shrinking files will likely fragment your tables, particularly larger onces, as contents of tables get moved about within the file, so once shrunk it's a good idea to defragment your tables. This, of course, will make your files grow again, but probably not so large as they were before you dropped your old tables. (Err, that assumes that the dropped tables contained large quantities of data...)