How SQLServer cleans up log files
This article is about how SQLServer cleans up log files. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Most of the time, the log file of SQLSERVER is not read, but after a long time, it is enough to burst the disk, so it is necessary to clean up the log file. Using the following method, after testing in the real environment, 400G log files are cleaned up in 1 second.
Operation steps
1. Change the recovery model to "simple"
Right-click Database-Properties, switch to options, and change the recovery model to simple.
two。 Shrink log
Right-click database-task-shrink-file
Once confirmed, you will find that the log files have been cleaned up quickly.
3. Command operation
Name of database to be cleaned by USE [master] GOALTER DATABASE-name of database to be cleaned by SET RECOVERY SIMPLE WITH NO_WAITGOALTER DATABASE-- name of database to be cleaned by simple mode GOUSE GODBCC SHRINKFILE (name of database to be cleaned by N' _ log', 2, TRUNCATEONLY)-set the size of the compressed log to 2m You can specify the name of the database to be cleaned by GOUSE [master] GOALTER DATABASE, the name of the database to be cleaned by SET RECOVERY FULL WITH NO_WAITGOALTER DATABASE, SET RECOVERY FULL-- restore to full mode GO, thank you for reading! This is the end of the article on "how to clean up log files in SQLServer". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!