How to compress the size of the MSSQL database log

Source: Internet
Author: User
Tags file size log mssql sql query
Data | database | Log |mssql| compression

The database in the cumulative operation process, not only its own volume will slowly grow, its log capacity size as well as the database entity file growth and will occupy a lot of space. the size of the MSSQL database contains two sections of data and transaction logs (TransactionLog).

The data part stores the data in the user's database, including the user's data tables, views, stored procedures, and so on.
The data section is typically stored in the. mdb file in the database filegroup. In general, in the case of normal use, this
The size of a section does not change very often, unless it is used to store fast-changing data such as the Forum
Capacity. In general, this section rarely needs to be narrowed.

The transaction log stores transaction records for user database operations, primarily for failure at the database server (more than
such as after a power failure, to restore data integrity in the database. This section is typically stored in a database file
In the. ldf file in the group. The size of this section is often drastically changed.

In some cases, the problem of writing a user's query statement (SQL statement) causes the database file size
The rapid expansion, especially the log files, can become very large. The database needs to be shrunk at this time. Reduced operations
is divided into two steps:

To truncate the contents of a log in a database
BACKUP LOG database name with TRUNCATE_ONLY

Step two force the database to compress its size
DBCC shrinkdatabase (database name, truncateonly)

These two steps need to be performed using Query Analyzer. For its specific meaning, please refer to the database included in the MSSQL
Transact-SQL Help files.

Another way to do this is to set the failover >> model to simple in the database properties >> options of the MSSQL Enterprise Manager, and then determine that the volume of the log file can also be reduced directly.




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.