Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 .mdf and .ldf files

Author  Topic 

cognos79
Posting Yak Master

241 Posts

Posted - 2006-12-27 : 10:31:43
when i create a new database using the wizard they are created automatically. why do we need them? what is the purpose

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-12-27 : 10:39:46
From BOL:

quote:
.mdf - Primary data file
.ldf - Transaction log file

The primary file contains the startup information for the database. The primary file is also used to store data. Every database has one primary file.

Transaction log files hold the log information used to recover the database. There must be at least one transaction log file for each database, although there may be more than one.



Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-12-27 : 10:42:06
quote:
Originally posted by cognos79

when i create a new database using the wizard they are created automatically. why do we need them? what is the purpose



MDF files hold the database objects. LDF files hold the database trasactions.





CODO ERGO SUM
Go to Top of Page

cognos79
Posting Yak Master

241 Posts

Posted - 2006-12-27 : 10:43:11
harsh...does it mean that I can restore the database from one of these files if the database is broken???

also can i view the contents of these .mdf and .ldf files???
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-12-27 : 10:53:28
Yes, there are some third party tools available which will allow you to restore database from log file, but you should not rely on using such tools. Maintaining regular database backups is a good strategy.

Also, you can't directly view the contents of any of these files.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

cognos79
Posting Yak Master

241 Posts

Posted - 2006-12-27 : 11:09:58
Thanks a lot guys...
Go to Top of Page

maheshcr
Starting Member

1 Post

Posted - 2007-01-02 : 20:12:19
What are the tools available to restore database from just the .LDF file?

Thanks for any help,

Mahesh
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2007-01-02 : 20:19:31
there are NO tools that can gurantee to restore from log file alone. depends on recovery model among other factors. as Harsh said, maintain regular backups. as though your job depended on it...because it probably does... :)
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-01-03 : 03:52:27
"What are the tools available to restore database from just the .LDF file?"

None that I know of. But there are tools that will "read" the LDF file, and from that transactions that occurred during a period of time can be "selectively" re-run

With the database in Full recovery model it is better to just rely on the backups which allow you to:

Restore from last FULL backup (e.g. last night, or last-Sunday etc.)
Restore more recent DIFF backup (optional)
Restore ALL subsequent TRANSACTION backups up to the time the restore is required - it is possible to restore the last Trans. backup to a specific TIME - rather than having to restore the whole file.

Kristen
Go to Top of Page
   

- Advertisement -