DBCC (Database consistency checker) act as Database console commands for SQL Server to check database consistency.
They are grouped as:
A brief description of the DBCC command categories is given below.
Maintenance: Maintenance tasks on a database, index, or filegroup.
Miscellaneous: Miscellaneous tasks such as enabling trace flags or removing a DLL from memory.
Informational: Tasks that gather and display various types of information.
Validation: Validation operations on a database, table, index, catalog, filegroup, or allocation of database pages.
Uses Of DBCC:
DBCC give details in form of statistics about the SQL Server. They can be used for Maintenance of database, index, or filegroup. DBCC Commands can be used to perform validation operations on a database, table, index, catalog, filegroup, or allocation of database pages.
They can perform miscellaneous tasks such as enabling trace flags or removing a DLL from memory. DBCC INDEXDEFRAG, DBCC ERRORLOG, DBCC CACHESTATS are one of the few DBCC commands
List of frequently used DBCC Command
- DBCC CHECKCATALOG
Used to perform consistency check for a table/catalog for a particular database.
- DBCC CHECKCONSTRAINTS
Used to check integrity of a particular constraint or all constraints on a particular table for a database.
- DBCC CHECKALLOC
Used to check page usage and allocation of a database.
- DBCC CHECKTABLE(tablename)
Used to verify data page integrity, page offsets, data page links, page pointers, index pointers, index sort order for a specified table.
- DBCC SQLPERF(logspace)
Displays T-log size and space used % for all databases.
- DBCC SHOWFILESTATS
Display Extent information for a database.
- DBCC CHECKIDENT(tablename)
Used to check identity information or to return current identity value for a particular table.
- DBCC TRACEOFF
Used to disable tracing
- DBCC TRACEON
Used to enable tracing.
- DBCC TRACESTATUS
Displays the trace status.
- DBCC USEROPTIONS
Displays the active SET options for a particular database
- DBCC INPUTBUFFER(sessionid)
Used to get the last statement sent by session to SQL server.
- DBCC SHRINKDATABASE(databasename)
Used to shrink data and log files for a particular database. It release the free space to OS.
- DBCC SHRINKFILE(file_id)
Used to shrink individual database files.
- DBCC LOGINFO
Displays virtual log file information contained in a T-log file.
- DBCC HELP(<dbcc command>)
Displays the syntax of a DBCC command. To know syntax of DBCC SQLPERF, execute
- DBCC MEMORYSTATUS
Displays SQL Server memory allocation status.
- DBCC Cleantable
Used to reclaim space from dropped variable length columns in tables/indexed views
- DBCC Opentran
Displays information about oldest active transaction and oldest distributed and non-distributed replication transaction
For more commands, please log on to: http://sqlschool.com/SQL-DBA-Course.html
or email to our trainer: firstname.lastname@example.org
We offer free technical support for this type of informational queries.