Why do we need LDF files along with MDF files?

What happens if I delete a file .ldfthat is in the same folder as my file .mdf?

+3
source share
4 answers

The LDF file is a transaction log and is required for all SQL server configurations. Depending on recovery modedetermine how it will be used. However, all queries are basically saved here until they are successfully transferred to the database (MDF).

You cannot delete it while SQL Server is running. You can detach the database, delete the log file (LDF) and reconnect the data file (MDF). However, it will simply create a new log file. You really don't need to delete it. If it gets too big, you will need to manage it, usually through the backup process.

+15
source

The database will be marked suspicious of rebooting SQL Server and is not accessible without any indentations to restore it.

LDF is an integral part of the database: you need this file.

You can, of course, ignore us and delete it and see for yourself ...

+3
source

, .LDF , ..LDF , SQL .

, , .LDF, , SQL Server . , , :

File activation failure. The physical file name "<<filename.ldf>>" may be incorrect.
Msg 945, Level 14, State 2, Line 1
Database '<<DB Name>>' cannot be opened due to inaccessible files or insufficient
memory or disk space.  See the SQL Server errorlog for details.
Msg 5069, Level 16, State 1, Line 1
ALTER DATABASE statement failed.

, , , . - . .

  • DB DB
  • .MDF
  • (, , , )
  • .MDF .

:

SP_ATTACH_SINGLE_FILE_DB @dbname='<<DBName>>' ,@physname=N'<<filepath\filename.MDF>>'

:

File activation failure. The physical file name "<<Filepath\filename.ldf>>" 
may be incorrect.
New log file '<<Filepath\filename.ldf>>' was created.

.

The question about the $$$$ million remains - why would anyone delete the .LDF file ???

Rajah

+1
source

The best way to keep the size .LDF fileunder control:

  • make regular backups of the transaction log at least once a day or
  • change the recovery model from full to simple (default, full)
0
source

All Articles