/  2
The Database Console Commands (DBCC)

Those of you familiar with previous versions of SQL Server might know the DBCC
statements as the Database Consistency Checker. All documentation now refers to them
as the Database Console Commands, probably in deference to the fact that not all of them
are used for database consistency checks.

Running DBCC statements are an integral part of database maintenance. Some, such as
DBCC CHECKDB, can be run on a scheduled basis (this is the one the wizard runs) as a

preventative measure, and others, such as DBCC SHRINKFILE, you can choose to run
when needed, table below lists some of the DBCC statements commonly used for
database maintenance.

Database Maintenance DBCC Statements
DBCC
Function
CHECKDB
Checks allocation and integrity of all DB objects
CHECKALLOC
Checks the consistency of disk space allocation
CHECKTABLE
Checks the integrity of the specified table and its indexes
SHRINKDATABASE
Attempts to shrink all data files in the specified database
SHRINKFILE
Attempts to shrink a specified data file
SHOWCONTIG
Displays fragmentation information on a table and its indexes
DBREINDEX
Rebuilds indexes for a specified table
INDEXDEFRAG
Defragments indexes for a specified table or view
Detecting and Resolving Database Corruption

Several of the DBCC statements have the ability to detect and attempt to repair
corruption in the database. Power failures or spikes, hardware glitches, or even internal
SQL Server errors can cause this corruption. The primary validation DBCCs are the

CHECK statements listed here:
DBCC CHECKDB
DBCC CHECKALLOC
DBCC CHECKCATALOG
DBCC CHECKCONSTRAINTS
DBCC CHECKFILEGROUP
DBCC CHECKIDENT
DBCC CHECKTABLE

Share & Embed

More from this user

Add a Comment

Characters: ...