Compress the database with the transact-SQL command

Source: Internet
Author: User

Use transact - SQL commands compress Databases
You can use the DBCC shrinkdatabase and DBCC shrinkfile commands to compress the database. The DBCC shrinkdatabase command compresses the database, DBCC The shrinkfile command compresses the specified files in the database.
( 1 ) DBCC Shrinkdatabase
DBCC The shrinkdatabase command syntax is as follows:
DBCC Shrinkdatabase (database_name [ , Target_percent ]
[ , {Notruncate | truncateonly} ] )
Parameters are described as follows:
· Target _ percent indicates the percentage of unused space in the database size after the database is compressed. If the specified percentage is too large and exceeds the proportion of space not used before compression, the database will not be compressed. In addition, the compressed database cannot be smaller than the initial capacity set by the database.
· Notruecate
After the database is reduced, the remaining space is retained in the database and will not be returned to the operating system.
. If this option is not selected, the remaining space is returned to the operating system.
· Truncateonly
After the database is reduced, the remaining space is returned to the operating system. When using this command, SQL Server reduces the file to the last file allocation, but does not move any data files. If this option is selected, the target_percent option is invalid.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.