What are mdf,ndf,ldf files and how to see the data in those
files?

Answer Posted / ravi santlani

MDF is the main database files - It's a SQL Data files where all the data in the database objects are stored in. (like tables, stored procedures, views, triggers etc are stored in the mdf file of sql server). This is the reason whey we use .MDF file to attache the database. Once we attach the .mdf we were able to see all the data exist in that respective database.


LDF is the log files - The size of the log file(ldf) is determined my the logging level you have set up on the database. Simple, full, and buld logged are the options. Simple being the least, and full being the most. The log (if in full) will alow you to re-apply transactions to the databse incase of a failure. If your looking for some performance improvement, there are a lot of things that can be done.

Just to focus on the files you could more the location of the LDF file to a separate physical drive. This will increate performance because writing to the log and writing to the mdf files wont compete for each other for throughput tot he drive.


NDF are secondary databse files (Same as mdf, but you can only have 1 Main database file).


You can also create a NDF file for the databese, and change some of the tables to be stored on this NDF. This file also could be stored on a separate physical drive. Some advantages to this are:

Tables that are written to most frequently are stored in one file, and tables that are relatively static are in another. Having to smaller file to write to for transactions will help with throughput.

Is This Answer Correct ?    46 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a SQL query to make a column as unique?

629


what is raid and what are different types of raid configurations? : Sql server database administration

536


How to create an index on a view?

584


Explain the difference between function and stored procedure?

513


What are points to remember while using the fillfactor argument?

530






How to concatenate two binary strings together?

615


What is data file in computer?

544


How can we call UDF(User Define Function) using C# code in ASP.net ?

5937


what is a check constraint?

638


Difference between aggregate functions of sql?

651


Which tcp/ip port does the sql server run on? How can it be changed?

525


What is intellisense?

587


Define right outer join?

544


You have modified 100 store procedures and want to replicate these changes from development to prodution, and production can have users using the Server/DB, how would you replicate without causing issues?

1722


Your sql server is running out of disk space. You notice that there are several large files with ldf extensions what are these files?

611