?
Solved

.mdf and .ldf

Posted on 2008-02-08
10
Medium Priority
?
660 Views
Last Modified: 2008-02-20
Hi can someone please give me a brief explaination of whet the following files are used for

.mdf (main data file)

.ldf (log data file)

Thanks
0
Comment
Question by:ac_davis2002
  • 3
  • 2
  • 2
  • +2
10 Comments
 
LVL 6

Accepted Solution

by:
Geyybecca earned 500 total points
ID: 20851095
in simple terms they are best discribe thus
the MDF file is the REAL data. The LDF file are changes yet to be merged into the live data, IE yet to be commited to the database
0
 
LVL 75

Assisted Solution

by:Aneesh Retnakaran
Aneesh Retnakaran earned 1000 total points
ID: 20851128
mdf -> actually stores the data
ldf -> stores the log of how that db was affected
0
 

Author Comment

by:ac_davis2002
ID: 20851189
mmmm

ok mdf stores the data, ldf is this uncommited data or a log of the changes to the db?
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 17

Expert Comment

by:dbaSQL
ID: 20851203
per MSFT:

MDF is the standard data file extension for SQL Server --  ' Main data file '
LDF is the standard log file extension for SQL Server  -- ' Log data file '
0
 
LVL 75

Assisted Solution

by:Aneesh Retnakaran
Aneesh Retnakaran earned 1000 total points
ID: 20851228
>ok mdf stores the data, ldf is this uncommited data or a log of the changes to the db?
exactly, You can have more than one data file in that case the extension will be ndf
0
 

Author Comment

by:ac_davis2002
ID: 20851250
isee so mdf stored the data

ldf is uncommited data

ndf is a log of the changes to the db from the data?
0
 
LVL 17

Assisted Solution

by:dbaSQL
dbaSQL earned 500 total points
ID: 20851269
NDF is the extension associated w/SQL's secondary data files.  as aneesh said, you can have more than one data file within the database.  subsequent to the first, they are extensioned .ndf
0
 
LVL 6

Expert Comment

by:Geyybecca
ID: 20851288
In an SQL database there are  is normally two files (you can have more) - an .ldf and an .mdf file. The .ldf file is a log file, and the .mdf file is the 'master data file'. There are also secondary data files (with the extension .ndf this is the naming data file) its the ldf that keeps a log of data to be committed to the Master Data File MDF)
0
 

Author Comment

by:ac_davis2002
ID: 20851310
Thanks chaps
0
 
LVL 42

Expert Comment

by:dqmq
ID: 20851447
>ldf is this uncommited data or a log of the changes to the db

While, the .ldf files are certainly used to store the log, that doesn't really say too much.  What is the log used for.  Every change made to the database is recorded in the log.   The log is an interim record of database changes in sequential order.  By "interim", I mean that updates are held in the log until a "checkpoint".  At which time the data files are brought up-to-date from the log.  

It's not true that everything in the log is uncommitted. Nor is it true that uncommitted updates only exist in the log.  Uncommitted udpdates get posted to the data file at a checkpoint, just like other changes.  If this were not true, it would be difficult for a database with long running transactions to ever take a checkpoint.

The log is also instrumental in recording transaction boundries.  The log can then be used to undo changes when they rollback.  

The log can also be used to help recover a database to a point-in-time.

Because of the instrumental role, the log should be on a separate disk from the data file and it's best put on a fast disk with redundancy.  



     
0

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This shares a stored procedure to retrieve permissions for a given user on the current database or across all databases on a server.
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Suggested Courses

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question