What is the difference between the MDF and LDF file ?
The .MDF file is the primary data file of a SQL database. The .LDF file is the transaction log file of a SQL database. The transaction log is used to guarantee the data integrity of the database and for data recovery. Data integrity is implemented by design and can't be configured by the database administrator. Data recovery is implemented by design and is configurable by the database administrator.
In SQL Server you have 3 different data recovery models: Simple, Full and bulk-logged. Typically, a database uses the Full recovery model or Simple recovery model.
What is the main difference between Full and Simple?
- Simple: No transaction log backups. Changes since the most recent backup are unprotected. In the event of a disaster, those changes are lost and need to be redone. You can only recover to the end of a backup.
- Full: Requiers transaction log backups. No work is lost due to a lost or damaged data file. Can recover to a specific point in time, assuming that your backups are complete up to that point in time. For example, prior to application or user error.
What is in the transaction log in the Simple recovery model ?
All open transactions. This means not committed transactions. This is called the active part of the transaction log. At the moment a transaction is committed it will be truncated from the transaction log. Log truncation automatically frees disk space for reuse by the transaction log. The biggest size of the transaction log will be the size of all open transactions at one moment. Therefor in a 'normal' SQL production database the transaction log file will never get very big.
What is in the transaction log in the Full recovery model ?
All committed transaction (inactive part) and open transactions (active part). The log records cannot be truncated untill all its log records have been captured in a transaction log backup. The log is truncated when you backup the transaction log.
What can we do to lower the size of the transactional log file (LDF)?
It depends on the configured recovery model of your database, what you can do. The recovery model of your database can be found in the properties of the database:
or via SSMS:
Open a query window and select the database.
USE
SELECT Recovery_model_desc FROM sys.databases WHERE Name = db_name()
What to do if your recovery model is: FULL?
Check if you are making transactional backups on a reguler time interval. If you only make full backups your transaction log will always grow and will never be truncated. In case you never want to lose data in case of a application or user error. Start making transactional log backups. If a database restore to the latest full backup is acceptable, you can switch the recovery model of your database to simple. Before switching the recovery model of your database please read next document: Considerations from switching the recovery model of your database. After switching to the recovery model Simple , you can shrink the log file. See the end of this blog how to do this.
What to do if your recovery model is: Simple?
Shrink the log file.
To set the recovery model to Simple you can run next query:
ALTER DATABASE
SET RECOVERY SIMPLE
To set the recovery model to FULL you can run next query:
ALTER DATABASE
SET RECOVERY FULL
How many free space is available in my log file?
- Select the database in the Object Explorer
- Point to Tasks, Point to Shrink and then click Files.
- Select File Type: Log
- Currently allocated: The current size of your log file
- Available free space: The free space in your log file
- Select the database in the Object Explorer
- Point to Tasks, Point to Shrink and then click Files.
- Select File Type: Log
- Select Release unused space
- Press OK to start the shrink process. If you do not want to shrink the log file press the cancel button.
78 comments:
I seldom work with sql server and files too. But once I couldn't use my files,because of they were corrupted. And fortunately I incidentally entered in the Internet and observed there - sql server repair database. The utility resolved my issue for a minute and free of charge as I bore in mind.
Hello Dear,
i had many confusion about mdf, ldf ndf files of sql server database. after reading your article, i am mostly satisfy.
I have also written article about database recovery software.
Nice articcal
This article helped me in shrinking the log file size. Very nice indeed. Helped me a lot... I recovered 7Gigs of space. Thanks!
i have a database my mdf fils is 139 mb & ldf file is 29.7 gb I've taken transaction log backup and then shrink database file it is reduced but only 1 gb what should i do to reduce the size of ldf file (gmailbackup@sify.com)
i have a database my mdf fils is 139 mb & ldf file is 29.7 gb I've taken transaction log backup and then shrink database file it is reduced but only 1 gb what should i do to reduce the size of ldf file (gmailbackup@sify.com)
HI André,
I also wrote an article on this topic. I cover all the possible causes of growing transaction log file as well as possible solutions. Please have a look on this article: Decrease Transaction Log File Size
All mankind love a lover,
Alter your database to simple recovery model and then shrink LDF to 1.
ALTER DATABASE SET RECOVERY SIMPLE
DBCC SHRINKFILE(,1)
All mankind love a lover,
Alter your database to simple recovery model and then shrink LDF to 1.
ALTER DATABASE "DBNAME" SET RECOVERY SIMPLE
DBCC SHRINKFILE("Logical Name of your Logfile",1)
It's a smart blog. I mean it seriously. You have so much knowledge on this subject and so much passion. He also knows how to get people to join him, obviously from the answers.
360DigiTMG Business Analytics Course in Bangalore
I really appreciate this wonderful message you have given us. I assure you that would be beneficial for most people.
360DigiTMG Data Analytics Course in Bangalore
Amazing Article ! I would like to thank you for the efforts you had made for writing this awesome article. This article inspired me to read more. keep it up.
Simple Linear Regression
Correlation vs covariance
data science interview questions
KNN Algorithm
Logistic Regression explained
I truly like only reading every one your web logs. Simply desired to in form you which you simply have persons such as me that love your own work out. Absolutely an extraordinary informative article. Hats off to you! The details which you have furnished is quite valuable. Tableau Course in Bangalore
Fantastic article I ought to say and thanks to the info. Instruction is absolutely a sticky topic. But remains one of the top issues of the time. I love your article and look forward to more.
Data Science Training Institute in Bangalore
Very wonderful informative article. I appreciated looking at your article. Very wonderful reveal. I would like to twit this on my followers. Many thanks! .
Cyber Security Course In Bangalore
Maybe you can make short video about it for tiktok? On this site https://soclikes.com/buy-tiktok-likes you can get tiktok likes
I'm really thankful that I read this. It's extremely valuable and quite informative and I truly learned a great deal from it.
Data Science Course In India
Nice to be seeing your site once again, it's been weeks for me. This article which ive been waited for so long. I need this guide to complete my mission inside the school, and it's same issue together along with your essay. Thanks, pleasant share.
Data Science Course Syllabus
I have to search sites with relevant information ,This is a
wonderful blog,These type of blog keeps the users interest in
the website, i am impressed. thank you.
Data Science Course in Bangalore
Excellent Blog! I would like to thank for the efforts you have made in writing this post. I am hoping the same best work from you in the future as well. I wanted to thank you for this websites! Thanks for sharing. Great websites!
Data Science Training in Bangalore
I am a new user of this site, so here I saw several articles and posts published on this site, I am more interested in some of them, hope you will provide more information on these topics in your next articles.
data analytics training in bangalore
Useful information, Thank you for sharing...
Data science training in chennai
Data science course in chennai
Đặt vé máy bay tại Aivivu, tham khảo
mua ve may bay di my
đăng ký bay từ mỹ về việt nam
vé máy bay đà nẵng nha trang
vé máy bay nha trang phú quốc
giá vé máy bay đi Huế
Thanks for posting the best information and the blog is very helpful.data science interview questions and answers
I found Habit to be a transparent site, a social hub that is a conglomerate of buyers and sellers willing to offer digital advice online at a decent cost.
Data Science Course in Pune
Excellent Blog! I would like to thank for the efforts you have made in writing this post. I am hoping the same best work from you in the future as well. I wanted to thank you for this websites! Thanks for sharing. Great websites!
Data Science Training in Bangalore
i am glad to discover this page : i have to thank you for the time i spent on this especially great reading !! i really liked each part and also bookmarked you for new information on your site.
data scientist course in bangalore
Great post i must say and thanks for the information. Education is definitely a sticky subject. However, is still among the leading topics of our time. I appreciate your post and look forward to more.
Data Science Course in Bangalore
Thanks for posting the best information and the blog is very helpful.data science institutes in hyderabad
I like to see websites that include the price of free shipping from the excellent helpful resource. I really enjoyed reading your post. Thank you!
Data Analytics Course in Bangalore
I want to leave a little comment to support and wish you the best of luck.we wish you the best of luck in all your blogging enedevors.
data science course
I want to leave a little comment to support and wish you the best of luck.we wish you the best of luck in all your blogging enedevors.
data science course in chennai
I am glad to discover this page. I have to thank you for the time I spent on this especially great reading !! I really liked each part and also bookmarked you for new information on your site.
Data Science Training in Chennai
Stupendous blog huge applause to the blogger and hoping you to come up with such an extraordinary content in future. Surely, this post will inspire many aspirants who are very keen in gaining the knowledge. Expecting many more contents with lot more curiosity further.
data science course in faridabad
Great to become visiting your weblog once more, it has been a very long time for me. Pleasantly this article i've been sat tight fosuch a long time. I will require this post to add up to my task in the school, and it has identical subject along with your review. Much appreciated, great offer. data science course in nagpur
Thanks for posting the best information and the blog is very important.data science course in Lucknow
I want to leave a little comment to support and wish you the best of luck.we wish you the best of luck in all your blogging enedevors.
data science course
It is late to find this act. At least one should be familiar with the fact that such events exist. I agree with your blog and will come back to inspect it further in the future, so keep your performance going.
Best Data Science Courses in Bangalore
I wanted to leave a little comment to support you and wish you the best of luck. We wish you the best of luck in all of your blogging endeavors.
Data Analytics Course in Bangalore
Extremely overall quite fascinating post. I was searching for this sort of data and delighted in perusing this one. Continue posting. A debt of gratitude is in order for sharing. python course in delhi
I want to leave a little comment to support and wish you the best of luck.we wish you the best of luck in all your blogging enedevors.
aws training in hyderabad
I was basically inspecting through the web filtering for certain data and ran over your blog. I am flabbergasted by the data that you have on this blog. It shows how well you welcome this subject. Bookmarked this page, will return for extra. data science course in jaipur
I am a new user of this site, so here I saw several articles and posts published on this site, I am more interested in some of them, will provide more information on these topics in future articles.
data science course in london
I want to leave a little comment to support and wish you the best of luck.we wish you the best of luck in all your blogging enedevors.
iot training in hyderabad
Amazing Article! I would like to thank you for the efforts you had made for writing this awesome article. This article inspired me to read more. keep it up.If you are Searching for info click on given link
Data science course in pune
Informative blog
best digital marketing institute in hyderabad
I am glad to discover this page. I have to thank you for the time I spent on this especially great reading !! I really liked each part and also bookmarked you for new information on your site.
Data Science Course in Delhi
i am glad to discover this page : i have to thank you for the time i spent on this especially great reading !! i really liked each part and also bookmarked you for new information on your site.
data engineering course in india
I am a new user of this site, so here I saw several articles and posts published on this site, I am more interested in some of them, will provide more information on these topics in future articles.
Digital Marketing Course in Bangalore
It's like you've got the point right, but forgot to include your readers. Maybe you should think about it from different angles.
Best Data Science Courses in Bangalore
You have completed certain reliable points there. I did some research on the subject and found that almost everyone will agree with your blog.
Data Analytics Course in Bangalore
First You got a great blog .I will be interested in more similar topics.I commend you for your excellent report on the knowledge that you have shared in this blog.
digital marketing training in hyderabad
free digital marketing course in hyderabad
Fantastic article I ought to say and thanks to the info. Instruction is absolutely a sticky topic. But remains one of the top issues of the time. I love your article and look forward to more.
Data Science Course in Bangalore
I truly appreciate just perusing the entirety of your weblogs. Just needed to educate you that you have individuals like me who value your work. Unquestionably an extraordinary post. Caps off to you! The data that you have given is exceptionally useful.artificial intelligence course in noida
Nice article with valuable information. Thanks for sharing.
AWS Training in Chennai | AWS Training institute in Chennai
I want to leave a little comment to support and wish you the best of luck.we wish you the best of luck in all your blogging enedevors
iot training in noida
Amazingly by and large very interesting post. I was looking for such an information and thoroughly enjoyed examining this one. Keep posting. An obligation of appreciation is all together for sharing.data science training in gwalior
Very informative message! There is so much information here that can help any business start a successful social media campaign!
Data Analytics Course in Gorakhpur
Wonderful blog. I am delighted in perusing your articles. This is genuinely an incredible pursuit for me. I have bookmarked it and I am anticipating perusing new articles. Keep doing awesome!
data analytics training in hyderabad
Extraordinary blog went amazed with the content that they have developed in a very descriptive manner. This type of content surely ensures the participants to explore themselves. Hope you deliver the same near the future as well. Gratitude to the blogger for the efforts.
Data Science Training
wow, great, I was wondering how to cure acne naturally. and found your site by google, learned a lot, now i’m a bit clear. I’ve bookmark your site and also add rss. keep us updated. PMP Course in Malaysia
Extremely overall quite fascinating post. I was searching for this sort of data and delighted in perusing this one.
Continue posting. A debt of gratitude is in order for sharing.
data science training in gwalior
Amazingly by and large very interesting post. I was looking for such an information and thoroughly enjoyed examining this one. Keep posting. An obligation of appreciation is all together for sharing.data science course in bhubaneswar
Very informative message! There is so much information here that can help any business start a successful social media campaign!
Data Science Course in Kolkata
I want to leave a little comment to support and wish you the best of luck.we wish you the best of luck in all your blogging enedevors
data scientist course in delhi
Very great post which I really enjoy reading this and it is not everyday that I have the possibility to see something like this. Thank You.
Best Online Data Science Courses
Amazingly by and large very interesting post. I was looking for such an information and thoroughly enjoyed examining this one.
Keep posting. An obligation of appreciation is all together for sharing.
data science course in gwalior
Extremely overall quite fascinating post. I was searching for this sort of data and delighted in perusing this one.
Continue posting. A debt of gratitude is in order for sharing.
data analytics course in kolhapur
The data scientists work on the raw data to take the right insights from it for making better decisions to make the business more prosperous.
data science training in patna
Develop technical skills and become an expert in analyzing large sets of data by enrolling for the Best Data Science course in Bangalore. Gain in-depth knowledge in Data Visualization, Statistics, and Predictive Analytics along with the two famous programming languages and Python. Learn to derive valuable insights from data using skills of Data Mining, Statistics, Machine Learning, Network Analysis, etc, and apply the skills you will learn in your final Capstone project to get recognized by potential employers.
Data Science Course in Jaipur
Get a comprehensive overview of Data Science and learn all the essential skills including collecting, modeling, and interpreting data. Register with Data Science institute Bangalore and build a strong foundation for a career where you will be involved in uncovering valuable information for your organization. Learn Python, Machine Learning, Big Data, Deep Learning, and Analytics to take center stage in Data Science.
Business Analytics Course in Jodhpur
Simply just, take a log backup and shrunk the log file to the maximum possible. If it's not working, check log_reuse_wait_desc in sys.databases for a particular database. The values, Replication, AVAILABILITY_REPLICA, and TRANSACTION indicate a running transaction waiting at replication, waiting for acknowledgement from secondary or a long-running transaction, respectively, and troubleshoot accordingly. If you need any further clarification or help, email me on krunalpatel155@gmail.com
Thanks,
Krunal
Companies are increasingly turning to data for decision-making and are depending on data professionals to do so. Develop strong logical and numerical aptitude and learn to work with R, Python, SQL, Hadoop, and statistical techniques like Linear Regression, Logistic Regression, etc. Sign up for the Data Scientist training in Bangalore, and gain expertise in using sophisticated analytical methods and statistical methods to prepare data for predictive and prescriptive modeling.
Data Scientist Course in Delhi
Are you searching for the best institute to start Data Science offline classes that will aid you in career growth, 360DigiTMG offers the best training with expert trainers and a job-ready curriculum. Enroll now!
Data Science Training in Delhi
"If you are also one of them and want to know what the companies demand from the data scientists to do in their organization, you have come to the right place.data science course in kolkata"
Your website is really cool and this is a great inspiring article.
data scientist training in Hyderabad .
Data Analytics training online course offers you abundant career opportunities. Experience the innovative online training delivered by 360DigiTMG. Get LMS access.
Data Analytics Course in Bangalore
Post a Comment