Tuesday, January 1, 2019

What is LDF and MDF

Master Database Files (MDF) and Log Database Files (LDF) are the primary files created for each database in the SQL Server environment.

Master Database File

MDF's are where all the database information is stored. It contains the rows, columns, fields and data created by an application or user. Database column creation, modifications and information record creation, modification are all stored within this file for searching and application use.

Log Database File

During various creation and modification process's within the MDF, all activity is logged in the LDF. As dynamic information is being processed in and out of memory, called transactions, data is stored in the LDF for error management. Consequently, all user activity is recorded for reference.



Comparison between MDF and LDF Files

MDF file is the primary file in SQL server database. The LDF is a supporting file. The latter stores the information related to transaction logs.

MDF contains database record data. LDF, on the other hand records information related to changes made in the server as well as all the actions performed.

Unlike MDF, LDF is primarily about three major operations that were mentioned earlier.
LDF files can go on to consume a lot of storage space depending on the number of changes made in the server as well as the number of transactions that took place. MDF, on the other hand can vary in its file size with the change of the table and record data.

No comments:

Post a Comment

How to use SQL pagination using LIMIT and OFFSET

  How to extract just a portion of a larger result set from a SQL SELECT. LIMIT n is an alternative syntax to the FETCH FIRST n ROWS ONLY. T...