CHECKDB
What is CHECKDB?
CHECKDB is a Microsoft SQL Server command used to verify the physical and logical integrity of a database. As part of the Database Console Commands (DBCC), it plays a crucial role in maintaining data consistency and detecting corruption within database files.
Read more
Key functions
- Integrity check: Scans for damaged pages, broken indexes, and inconsistent relationships.
-
Repair options: Identifies and can sometimes repair damaged structures.
-
Performance: Should be executed during low-load periods due to high resource usage.
-
Automation: Often included in scheduled maintenance plans via SQL Server Agent.
History
DBCC CHECKDB introducerades tidigt i SQL Server-historien som en ersättning för separata kontroller som CHECKALLOC och CHECKTABLE. Med tiden har den optimerats för att använda snapshot-teknik, vilket gör att den kan köras utan att låsa databasen. Från och med SQL Server 2005 har CHECKDB kunnat utnyttja Database Snapshots för att minska påverkan på driftmiljön.
Usage in Microsoft Environments
CHECKDB is integrated into SQL Server Management Studio (SSMS) and can be run through T-SQL or the graphical interface. In cloud-based services like Azure SQL Database, similar integrity checks are performed automatically, even though direct DBCC access is limited.
Summary
CHECKDB is an essential tool for database health management. Regular execution helps prevent data corruption, supports recovery efforts, and ensures long-term data reliability within SQL Server environments.