The cause of

Today, I found an online website of the company. I could not modify the data and reported failure all the time, but I could check the data.

So, go to the server to check the logs. Found log has been reported an error, a critical error, “disk space is insufficient”, check disk C, work 39.9G, available 0. This is a small site, not much disk space, but not much data.

Also, check the folder that occupies a large space. It is found in the folder “C:\Program Files\Microsoft SQL Server\ MSSQL14.mSSQLServer \MSSQL\DATA”, which occupies more than 20 GB. Next, you see that a file named “xxx_log. LDF” takes up 13GB.

MDF file and. LDF file

MDF, short for Primary Data File, holds the data information of a database.

.ldF, Log data files, is short for Log Data Files, which store the files that update the database (add, delete, modify)

The solution

Later, it was discovered that the problem could be resolved by shrinking the data database log

shrinkage

Shrinking a database is recycling unnecessary or unusable items from the database. It can also shrink database log files

The solution

ALTER DATABASE DATABASENAME SET RECOVERY SIMPLE -- Clear log DBCC SHRINKFILE (DATABASENAME_Log, 1) -- Shrink DATABASE to 1MBCopy the code

For example, the data name is test

ALTER DATABASE test SET RECOVERY SIMPLE; -- Clear DBCC SHRINKFILE (test_Log, 1); Shrink database to 1MBCopy the code

It can also be done through an interface

Select Log as the file type, and select the second shrink operation

Complete the WC…

Reference:

www.voidcn.com/article/p-q…

Blog.csdn.net/microcosmv/…

Blog.csdn.net/qq_42773229…