Is this like an “embedded” database of sorts? A file containing a built in database?
-
5If you've got just an mdf file, you may find http://serverfault.com/questions/31105/opening-mdf-files useful. – Dominic Rodger Jul 24 '09 at 05:53
-
A .mdf file might also contain an Microsoft Access database. An Access database is not a SQL server database, but indeed a more embedded type of database like a bit like e.g. SQLlite. The Access database needs no server software, just drivers. Access was more common in the 1990s but it is still updated and part of the Office package: https://en.wikipedia.org/wiki/Microsoft_Access – mortb Jan 28 '16 at 10:41
-
1I wish SO included a section for the *reason* a question is closed. I have no idea why this particular question was considered off topic. Is there another SO site dedicated to databases? If so why not link there. One of the biggest problems SO has is good questions with good answers being closed. Ensuring a reason has to be specified may be one way of mitigating this disease. – NeilG Mar 01 '22 at 00:27
2 Answers
SQL Server databases use two files - an MDF file, known as the primary database file, which contains the schema and data, and a LDF file, which contains the logs. See wikipedia. A database may also use secondary database file, which normally uses a .ndf extension.
As John S. indicates, these file extensions are purely convention - you can use whatever you want, although I can't think of a good reason to do that.
More info on MSDN here and in Beginning SQL Server 2005 Administation (Google Books) here.

- 52,327
- 25
- 125
- 193
-
4For people like me: Q: what do the letters mean? A: MDF – It stands for Master Database File (https://www.datanumen.com/blogs/5-basic-facts-mdf-ldf-files-sql-server/) – Vasily Hall May 22 '19 at 17:45
Just to make this absolutely clear for all:
A .MDF file is “typically” a SQL Server data file however it is important to note that it does NOT have to be.
This is because .MDF is nothing more than a recommended/preferred notation but the extension itself does not actually dictate the file type.
To illustrate this, if someone wanted to create their primary data file with an extension of .gbn they could go ahead and do so without issue.
To qualify the preferred naming conventions:
- .mdf - Primary database data file.
- .ndf - Other database data files i.e. non Primary.
- .ldf - Log data file.

- 41,005
- 9
- 72
- 84
-
46How about `mdf = main data file`, `ndf = next data file` and `ldf = log data file` ? – Bitterblue Nov 11 '14 at 09:56
-
@Bitterblue: Could be. May be I can use for explaining to my students ;) – now he who must not be named. Feb 19 '15 at 13:57
-
@Bitterblue Thanks a lot. Just, do we have any source for that information? – Muhamed Huseinbašić Dec 05 '15 at 10:27
-
2@nowhewhomustnotbenamed. just want to say you have a funny name.... – Syamsoul Azrien Apr 01 '16 at 08:35
-
1@SyamsoulAzrien: lol.. inspired by `harry potter` – now he who must not be named. Apr 01 '16 at 09:40
-
`mdf = master database file`. @VaibhavVishal `media descriptor file` pertains to optical disc images, not Db files. – Sep 12 '19 at 15:27