This article is about SQL Server’s TempDB System Database, and it is from my eBook:
Tuning SQL Server (Second Edition)
Table of Contents | Sample Chapter | Learn More
Introducing the TempDB System Database in SQL Server
The tempdb system database in SQL Server is one of the databases that are shipped with every SQL Server installation and it is used for specific tasks as a temporary storage. Examples of when tempdb is used are:
- Use of local/global temporary tables, stored procedures and variables.
- Use of cursors.
- When the SORT_IN_TEMPDB option is used during the creation or rebuild of indexes.
- Use of local/global stored procedures.
- When row versions are generated by different transactions.
TempDB System Database’s Restrictions and Special Characteristics
TempDB is protected with the use of certain built-in restrictions in SQL Server. These are:
- You cannot drop it.
- You cannot back it up/restore it.
- You cannot change the database owner (it is always the dbo).
- You cannot create a database snapshot.
- You cannot drop the guest user.
- You cannot add filegroups.
- You cannot change the collation (default collation is server’s collation).
- You cannot take the database offline.
- You cannot set the database or primary filegroup to READ_ONLY.
- You cannot run DBCC CHECKALLOC and DBCC CHECKCATALOG.
- You cannot rename the database or its primary filegroup.
- You cannot remove the primary filegroup, data or log file.
- TempDB cannot participate in database mirroring.
- You cannot enable change data capture on TempDB.
Strengthen your SQL Server Administration Skills – Enroll to our Online Course!
Check our online course on Udemy titled “Essential SQL Server Administration Tips”
(special limited-time discount included in link).Via the course, you will learn essential hands-on SQL Server Administration tips on SQL Server maintenance, security, performance, integration, error handling and more. Many live demonstrations and downloadable resources included!
TempDB Database’s Criticality in SQL Server Performance
TempDB is heavily used in a variety of SQL Server operations and contributes a lot to performance of database operations. To this end, you need to maintain the good health of TempDB in order to contribute towards a performant SQL Server instance. For example, you must ensure that there is an adequate amount of available free disk space as TempDB expands when used. Also, using multiple data files can help applying parallelism in TempDB database.
Learn more about SQL Server Performance Tuning in my latest eBook “Tuning SQL Server (second edition)”!
Featured Online Courses:
- Boost SQL Server Database Performance with In-Memory OLTP
- Essential SQL Server Administration Tips
- SQL Server Fundamentals – SQL Database for Beginners
- Essential SQL Server Development Tips for SQL Developers
- The Philosophy and Fundamentals of Computer Programming
- .NET Programming for Beginners – Windows Forms with C#
- Introduction to SQL Server Machine Learning Services
- Introduction to Azure SQL Database for Beginners
- SQL Server 2019: What’s New – New and Enhanced Features
- Entity Framework: Getting Started – Complete Beginners Guide
- How to Import and Export Data in SQL Server Databases
- Learn How to Install and Start Using SQL Server in 30 Mins
- A Guide on How to Start and Monetize a Successful Blog
Read Also:
- The Importance of Database Indexes
- Where are temporary tables stored in SQL Server?
- SQL Server 2016: TempDB Enhancements
- tempdb growth
- …more
Check our other related SQL Server Performance articles.
Subscribe to our newsletter and stay up to date!
Check out our latest software releases!
Check out our eBooks!
Rate this article:
Reference: SQLNetHub.com (https://www.sqlnethub.com)
© SQLNetHub
Artemakis Artemiou is a seasoned Senior Database and AI/Automation Architect with over 20 years of expertise in the IT industry. As a Certified Database, Cloud, and AI professional, he has been recognized as a thought leader, earning the prestigious Microsoft Data Platform MVP title for nine consecutive years (2009-2018). Driven by a passion for simplifying complex topics, Artemakis shares his expertise through articles, online courses, and speaking engagements. He empowers professionals around the globe to excel in Databases, Cloud, AI, Automation, and Software Development. Committed to innovation and education, Artemakis strives to make technology accessible and impactful for everyone.