.mdf and .ldf

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
ac_davis2002Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GeyybeccaCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Aneesh RetnakaranDatabase AdministratorCommented:
mdf -> actually stores the data
ldf -> stores the log of how that db was affected
0
ac_davis2002Author Commented:
mmmm

ok mdf stores the data, ldf is this uncommited data or a log of the changes to the db?
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

dbaSQLCommented:
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
Aneesh RetnakaranDatabase AdministratorCommented:
>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
ac_davis2002Author Commented:
isee so mdf stored the data

ldf is uncommited data

ndf is a log of the changes to the db from the data?
0
dbaSQLCommented:
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
GeyybeccaCommented:
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
ac_davis2002Author Commented:
Thanks chaps
0
dqmqCommented:
>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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.