Shrink Method
この機能は、将来のバージョンの Microsoft SQL Server では削除される予定です。 新しい開発作業では、この機能の使用を避け、現在この機能を使用しているアプリケーションは修正するようにしてください。
The Shrink method attempts to reduce the size of a referenced operating system file, or attempts to reduce the size of all operating system files maintaining the referenced Microsoft SQL Server database.
構文
object.Shrink(NewSize, Truncate)
Parts
object
Expression that evaluates to an object in the Applies To list.NewSize
Long integer that specifies a new target size as described in Settings.Truncate
Long integer that directs method behavior as described in Settings.
Prototype (C/C++)
HRESULT Shrink(long NewSize, SQLDMO_SHRINK_TYPE Truncate);
説明
For the Database object, the NewSize argument is set using any negative number or a number from 1 through 100. When negative, the Shrink method to attempts to shrink files maintaining the database to their smallest possible sizes. A positive value represents a percentage of the target reserved as unused space. For example, specify 5 to shrink a database leaving five percent free space for future growth.
For the DBFile and LogFile objects, the NewSize argument is set using any negative number, zero, or any positive integer. When negative, the Shrink method attempts to shrink the referenced file to its smallest possible size. Zero or a positive value represents a target file size as a number of megabytes.
Set the Truncate argument using these values.
SQLDMOShrink_Default
Data in pages located at the end of the file(s) is moved to pages earlier in the file(s). File(s) are truncated to reflect allocated space.SQLDMOShrink_EmptyFile
Migrate all data from the referenced file to other files in the same filegroup. (DBFile and LogFile object only)SQLDMOShrink_NoTruncate
Data in pages located at the end of the file(s) is moved to pages earlier in the file(s).SQLDMOShrink_TruncateOnly
Data distribution is not affected. File(s) are truncated to reflect allocated space, recovering free space at the end of any file.