Current location - Health Preservation Learning Network - Slimming men and women - How to shrink the database in SQL Server 2000
How to shrink the database in SQL Server 2000
This topic describes how to use SQL Server Management Studio.

Object Explorer in shrinks the database. The shrunk database cannot be less than the minimum size of the database. The minimum size is the size specified when the database was originally created, or the last file size change operation (for example

DBCC shrink file) settings. For example, if the size of the database is 10 MB when it is initially created, then it grows to 100 MB.

MB, the database can only be shrunk to 10 MB, even if all the data in the database has been deleted.

Shrink database

In Object Explorer, connect to the SQL Server database engine instance, and then expand the instance.

Expand the database, and then right-click the database you want to shrink.

Point to Tasks, point to Shrinking, and then click Database.

Alternatively, select the Reorganize files before releasing unused space check box. If this check box is selected, you must specify a value for the maximum free space in the shrink file.

Selecting this option has the same effect as specifying the target_percent value when executing DBCC to shrink the database. Clearing this option has the same effect as executing DBCC SHRINKDATABASE with TRUNCATEONLY option. TRUNCATEONLY shrinks the file to the last allocated area. This will reduce the file size without moving any data. By default, this option is cleared.

Enter the maximum percentage of free space remaining in the database file after shrinking the database. The allowed value is between 0 and 99. This option is available only if Reorganize files before freeing unused space is selected.

Click "OK".

Shrink database

while

When the database file in the database is too large or there are unused pages, you can shrink the database by shrinking the database. Similarly, transaction log files can be shrunk. Database files can be used as groups or

Manual shrinkage alone, or it can be set to automatically shrink at specified intervals. The activity of shrinking the database is performed in the background and does not affect the user activities in the database.

The operation steps are as follows:

(1) Open SQL Server Enterprise Manager. Double-click the open database node, right-click the name of the database to be shrunk, and select All Tasks → Shrink Database in the pop-up shortcut menu to open the Shrink Database dialog box, as shown in figure 1.

Figure 1 shrinking database

(2) Specify the shrinkage rate of the database, which can be selected from the following options.

Enter the amount of free space remaining in the shrink database in the Max Free Space in Shrink File text box. Based on the value of Database Size, Free Space. If the maximum available space is "25%", please set a percentage less than this value in this option, for example, "12%".

Select the "Move the page to the beginning of the file before shrinking" check box to keep the freed file space in the database file and move the page containing data to the beginning of the database file.

(3) In the "Schedule" option box, select whether to automatically perform database compression on a regular basis. Select the Shrink the database according to this schedule check box, and then click the Change button to create or change the frequency and time of automatically shrinking the database.

(4) Finally, click OK to finish the operation.