Reclaim space in SQL Server 2005 database when dropping tables permanently

后端 未结 2 1329
盖世英雄少女心
盖世英雄少女心 2020-12-12 02:01

I\'m dropping out massive numbers of tables out of a SQL Server 2005 database. How do I shrink the database - assuming I\'m not replacing the data or the tables? I\'m archiv

2条回答
  •  粉色の甜心
    2020-12-12 02:37

    DBCC Shrinkdatabase(0) --  Currently selected database
    

    or

    DBCC Shrinkdatabase() --  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...)

提交回复
热议问题