INF: Issues With Shrinking SQL Server DatabasesID: Q141163
|
SQL Server 6.0 has added the new command DBCC SHRINKDB which allows administrators to truncate some or all of the unused portion of a database at the end of its allocated space thus "shrinking" the allocated database size. It is important to note that this command does no data compaction and does not move data within the database to shrink the database to its least possible size. It simply starts from the end of the database and goes backwards until it finds the first place where any data or log resides, and determines it can truncate everything after that point. The data object can be a user table or a system table. If the object is a system table (except for SYSLOGS which is the transaction log), there is little the user can do to move the object and other options besides DBCC SHRINKDB.
As described in the Administrator's Companion, a SQL Server database
consists of 1/2 MB allocation units of 256 2KB pages each, and are
identified by the first page number in their unit; i.e., the first
allocation unit is 0, the second is 256, the third is 512, etc. DBCC
SHRINKDB will only shrink a databases on a 1 MB boundary (i.e., it won't
leave a 1/2 MB.) The allocation units for a database of 5 MB might be
simply represented like this:
0 256 512 768 1024 1280 1536 1792 2048 2304
A......A......A......A......A......A......A......A......A......A......
0 256 512 768 1024 1280 1536 1792 2048 2304
A......A......A......A......A......A......A......A......A......A......
^ ^ ^ ^ ^
T T T T T
0 256 512 768 1024 1280 1536 1792 2048 2304
A......A......A......A......A......A......A......A......A......A......
^ ^ ^
T T L
0 256 512 768 1024 1280 1536 1792 2048 2304
A......A......A......A......A......A......A......A......A......A......
^ ^
L T
Additional query words: sql6 sizing dbcc shrinkdb
Keywords : kbusage SSrvAdmin SSrvBCP SSrvTran
Version : 6.0
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: March 23, 1999