SQL Cleanup log file

Source: Internet
Author: User

    • Scene:

When we imported the Mr Data, we found that the disk space was not enough, the result is that our program is likely to throw an exception, we need to import data when the log to thin the body.

Q 1: When importing data, does weight loss result in database exceptions?

    • The DBA provides a solution:

Answer question 1:

No problem. Does not create a conflict. But make room for the day to prevent it from being filled.

1. Confirm that the recovery model for M_develop is simple.

See the script below.

Select Recovery_model_desc,name

From sys.databases

where Name= ' M_develop '

2. If not simple. Please change to Simple

Modify the script as follows:

Use [master]

GO

ALTER DATABASE [M_develop] SET RECOVERY simple with no_wait

GO.

3. After the recovery mode is simple. Confirm log size, and percent occupancy: The script is as follows:

DBCC SQLPERF (LOGSPACE)

4. If the database is simple, log space used (%) The log percentage should be smaller.

5. Shrink the log file size

Use M_develop

Go

--Find the log file name of the library

Select Name

From Sys.database_files

Where type_desc= ' log '

--to reduce the log, assuming that the above query results log name M_develop_log, shrink to 10G, then the script is as follows

DBCC SHRINKFILE (M_develop _log,10240)

--Check the log size again

DBCC SQLPERF (LOGSPACE)

(Note: The database schema is changed to simple for performance reasons.) If you do not change it, you need to back up logs, backup log. Not recommended)

SQL Cleanup log file

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.