Thursday, April 6, 2023

Difference between Data and Log file

Data and Log file

In a database management system, data files & log files both are used for different purposes.
The structure of the data file & log file is also different.

Data files: Data files are physical files that are located on a disk or on the network to share & keep actual data.
Data files contain tables, indexes, views, stored procedures, and other objects. 
A database may have one or more than one data file.
A database may have one or more than one filegroup.
A file group is a collection of one or more than one data file. 
Internally, the data file contains multiple pages.
As per Microsoft(MS), place data files & log files on separate drives to get better performance.
Data and Log Files
The type of data files is given below:
1) Primary Data Files:-
The system creates this type of file for a database.MDF extension.
2) Secondary Data Files:-
This type of file is optional & is also used to store data. 
We can create/add more than one secondary data file in a database that has.NDF extension.
PrimarySecondaryAndLogFiles

Log Files: Although they have a distinct structure, log files are still physical files.
The log file has the.LDF file extension.
The history of every transaction that has been carried out for the database is kept in the log file.
records all inserts, updates, deletions, backups, schema modifications, etc. 
Moreover, it guarantees data consistency and offers a means of recovering from system errors.
Transaction history is sequentially stored in the log file.
A database can have several log files added to it.
 

No comments:

Post a Comment

Featured Post

Use DBCC SQLPerf (logspace)

 Use DBCC SQLPerf (logspace) to monitor and optimize database performance in SQL Server. Let's Explore: Let's Explore: https://mades...

Popular Posts