Checking and Repairing Database Integrity

DBCC CHECKDB is a Transact-SQL command that is frequently used for checking the logical and physical integrity of databases. Essentially, DBCC CHECKDB is a superset command that actually runs three checks (CHECKALLOC, CHECKTABLE, and CHECKCATALOG) by issuing a single command.

The following are some recommendations for using DBCC CHECKDB to check and repair SQL database integrity:

• Always ensure that recent backups are on hand before running the command.

• Generally it is better to run the DBCC CHECKDB superset command than to execute the individual operations, because this will serve to identify the majority of the errors and is generally safe to run in a production environment.

• After DBCC CHECKDB has been run, the command can be run again with the REPAIR argument to repair reported errors. However, consideration should also be given to restoring the database from backup instead, because the REPAIR options should be considered a last resort.

DBCC CHECKDB can require a considerable amount of time to run against large databases, and it performs schema locks that prevent metadata changes. Therefore, it is highly recommended to run the command during nonproduction hours.

• For large databases, the command can be run with the PHYSICAL_ONLY option, which will limit checking to the integrity of the physical structure of the page and record headers, along with the allocation consistency of the database. For these larger databases, it is therefore recommended to run the command with the PHYSICAL_ONLY option on a more frequent basis, and perform a full run of DBCC CHECKDB only on a periodic basis.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset