DBCC

DBCC CHECKDB

DBCC CHECKDB – is the Database Console Command, and is very important to SQL Server. This command is used to check the physical and logical consistency of a database.


DBCC is Used To:

• Check for and fix database corruption issues.
• Checks each table one by one for data corruption issues.
• Checks values within tables to ensure that’s values are valid for that data type.
• Should be run regular.
• Should be run off hours
• Most expensive IO operations.



DBCC Internals:

When this command is issued it does run few commands that actually do the validation and do check if the pages are consistent and report if they are not. Basically, DBCC CHECKDB internally does below:

DBCC CHECKALLOC 

This check validates the disk space allocation and compares it with the internal structure of the pages, it can also repair the allocation structure if an anomaly is found. It runs at a database level.


DBCC CHECKTABLE 

This check integrity of the pages and structure for the table or indexed views, it also validates linkages between pages, sort orders, pointers and offset. This check runs at a table and view level.


DBCC CHECKCATALOG 

This check validates the consistency for data type used in the database and compares each of them with the systypes and sysobjects system table. This check runs at a database level.



Repair Levels

To repair a suspect database use following script:
DBCC CHECKDB(databaseNamerepair options)
  • REPAIR_REBUILD
  • REPAIR_FAST
  • REPAIR_ALLOW_DATA_LOSS

1. Repair_Rebuild


If a user wants to repair SQL database without any loss of information, then this repair option is selected.

2.Repair_Allow_Data_Loss:

The database should be set on single user mode to run REPAIR_ALLOW_DATA_LOSS. In some cases users take help of repair_allow_data_loss command to repair all type of errors in the SQL database. It is pretty much clear from the name that there might be some loss of data during the recovery process. This means this DBCC CHECKDB command does not promise data integrity.

3. REPAIR_FAST

Does minor fast repairs on database without risk of data loss such as repairing extra keys in nonclustered indexes.




Name

Azure Backup Database Clustering Crash Dumps DBCC Deadlock Link Server Log Shipping Maintenance Migration Mirroring Monitoring Performance Tuning Permissions Post Installations Prerequisites Replication Restore Database SQL Installations SQL on Linux SQL Uninstallations SSIS T-SQL Windows Server
false
ltr
item
hybriddba.blogspot.com: DBCC
DBCC
hybriddba.blogspot.com
https://hybriddba.blogspot.com/2019/04/dbcc.html
https://hybriddba.blogspot.com/
https://hybriddba.blogspot.com/
https://hybriddba.blogspot.com/2019/04/dbcc.html
true
7679493960263860249
UTF-8
Not found any posts Not found any related posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU Tag ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Contents See also related Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy