SlideShare a Scribd company logo
1.DBCC CHECKALLOC
DBCC CHECKALLOC checks page usage and allocation in the database. Use this command if allocation
errors are found for the database. If you run DBCC CHECKDB, you do not need to run DBCC CHECKALLOC,
as DBCC CHECKDB includes the same checks (and more) that DBCC CHECKALLOC performs.


2.DBCC CHECKCATALOG
This command checks for consistency in and between system tables. This command is not executed within the
DBCC CHECKDB command, so running this command weekly is recommended.

3.DBCC CHECKCONSTRAINTS
DBCC CHECKCONSTRAINTS alerts you to any CHECK or constraint violations.
Use it if you suspect that there are rows in your tables that do not meet the constraint or CHECK constraint
rules.

4.DBCC CHECKDB
A very important DBCC command, DBCC CHECKDB should run on your SQL Server instance on at least a
weekly basis. Although each release of SQL Server reduces occurrences of integrity or allocation errors, they
still do happen. DBCC CHECKDB includes the same checks as DBCC CHECKALLOC and DBCC
CHECKTABLE. DBCC CHECKDB can be rough on concurrency, so be sure to run it at off-peak times.

5.DBCC CHECKTABLE
DBCC CHECKTABLE is almost identical to DBCC CHECKDB, except that it is performed at the table level, not
the database level. DBCC CHECKTABLE verifies index and data page links, index sort order, page pointers,
index pointers, data page integrity, and page offsets. DBCC CHECKTABLE uses schema locks by default, but
can use the TABLOCK option to acquire a shared table lock. CHECKTABLE also performs object checking
using parallelism by default (if on a multi-CPU system).

6.DBCC CHECKFILEGROUP
DBCC CHECKFILEGROUP works just like DBCC CHECKDB, only DBCC CHECKFILEGROUP checks the
specified filegroup for allocation and structural issues. If you have a very large database (this term is relative,
and higher end systems may be more apt at performing well with multi-GB or TB systems ) , running DBCC
CHECKDB may be time-prohibitive.
If your database is divided into user defined filegroups, DBCC CHECKFILEGROUP will allow you to isolate
your integrity checks, as well as stagger them over time.

7.DBCC CHECKIDENT
DBCC CHECKIDENT returns the current identity value for the specified table, and allows you to correct the
identity value if necessary.

8.DBCC DBREINDEX
If your database allows modifications and has indexes, you should rebuild your indexes on a regular basis. The
frequency of your index rebuilds depends on the level of database activity, and how quickly your database and
indexes become fragmented. DBCC DBREINDEX allows you to rebuild one or all indexes for a table. Like
DBCC CHECKDB, DBCC CHECKTABLE, DBCC CHECKALLOC, running DBREINDEX during peak activity
times can significantly reduce concurrency.

9.DBCC INDEXDEFRAG
Microsoft introduced the excellent DBCC INDEXDEFRAG statement beginning with SQL Server 2000. This
DBCC command, unlike DBCC DBREINDEX, does not hold long term locks on indexes. Use DBCC
INDEXDEFRAG for indexes that are not very fragmented, otherwise the time this operation takes will be far
longer then running DBCC DBREINDEX. In spite of it's ability to run during peak periods, DBCC
INDEXDEFRAG has had limited effectiveness compared to DBCC DBREINDEX (or drop/create index).

10.DBCC INPUTBUFFER
The DBCC INPUTBUFFER command is used to view the last statement sent by the client connection to SQL
Server. When calling this DBCC command, you designate the SPID to examine. (SPID is the process ID, which
you can get from viewing current activity in Enterprise Manager or executing sp_who. )

11.DBCC OPENTRAN
DBCC OPENTRAN is a Transact-SQL command that is used to view the oldest running transaction for the
selected database. The DBCC command is very useful for troubleshooting orphaned connections (connections
still open on the database but disconnected from the application or client), and identification of transactions
missing a COMMIT or ROLLBACK. This command also returns the oldest distributed and undistributed
replicated transactions, if any exist within the database. If there are no active transactions, no data will be
returned. If you are having issues with your transaction log not truncating inactive portions, DBCC OPENTRAN
can show if an open transaction may be causing it.

12.DBCC PROCCACHE
You may not use this too frequently, however it is an interesting DBCC command to execute periodically,
particularly when you suspect you have memory issues. DBCC PROCCACHE provides information about the
size and usage of the SQL Server procedure cache.

13.DBCC SHOWCONTIG
The DBCC SHOWCONTIG command reveals the level of fragmentation for a specific table and its indices. This
DBCC command is critical to determining if your table or index has internal or external fragmentation. Internal
fragmentation concerns how full an 8K page is.
When a page is underutilized, more I/O operations may be necessary to fulfill a query request than if the page
was full, or almost full.
External fragmentation concerns how contiguous the extents are. There are eight 8K pages per extent, making
each extent 64K. Several extents can make up the data of a table or index. If the extents are not physically
close to each other, and are not in order, performance could diminish.

14.DBCC SHRINKDATABASE
DBCC SHRINKDATABASE shrinks the data and log files in your database.
Avoid executing this command during busy periods in production, as it has a negative impact on I/O and user
concurrency. Also remember that you cannot shrink a database past the target percentage specified, shrink
smaller than the model database, shrink a file past the original file creation size, or shrink a file size used in an
ALTER DATABASE statement.

15.DBCC SHRINKFILE
DBCC SHRINKFILE allows you to shrink the size of individual data and log files. (Use sp_helpfile to gather
database file ids and sizes).

16. DBCC TRACEOFF, TRACEON, TRACESTATUS
Trace flags are used within SQL Server to temporarily enable or disable specific SQL Server instance
characteristics. Traces are enabled using the DBCC TRACEON command, and disabled using DBCC
TRACEOFF. DBCC TRACESTATUS is used to displays the status of trace flags. You'll most often see
TRACEON used in conjunction with deadlock logging (providing more verbose error information).

17.DBCC USEROPTIONS
Execute DBCC USEROPTIONS to see what user options are in effect for your specific user connection. This
can be helpful if you are trying to determine if you current user options are inconsistent with the database
options.

More Related Content

PDF
HPE NonStop SQL WebDBS - Introduction
PPTX
PyCon DE 2013 - Table Partitioning with Django
PPTX
Lect 08 materialized view
PDF
Connecting To MS SQL Server With Mulesoft (Stored Procedure To Insert data)
PDF
ORACLE 12C DATA GUARD: FAR SYNC, REAL-TIME CASCADE STANDBY AND OTHER GOODIES
PPT
Les 07 Rman Rec
PPTX
Liquidating database frustrations with liquibase
PDF
161 Pdfsam
HPE NonStop SQL WebDBS - Introduction
PyCon DE 2013 - Table Partitioning with Django
Lect 08 materialized view
Connecting To MS SQL Server With Mulesoft (Stored Procedure To Insert data)
ORACLE 12C DATA GUARD: FAR SYNC, REAL-TIME CASCADE STANDBY AND OTHER GOODIES
Les 07 Rman Rec
Liquidating database frustrations with liquibase
161 Pdfsam

What's hot (10)

PPT
PPTX
Liquibase for java developers
PDF
Whitepaper Performance Tuning using Upsert and SCD (Task Factory)
PPT
High availability solutions bakostech
DOC
Steps for upgrading the database to 10g release 2
PPTX
Liquibase case study
PPT
Liquibase – a time machine for your data
PPTX
Successful DB migrations with Liquibase
PDF
Liquibase - Open Source version control for your database
KEY
Agile Database Development with Liquibase
Liquibase for java developers
Whitepaper Performance Tuning using Upsert and SCD (Task Factory)
High availability solutions bakostech
Steps for upgrading the database to 10g release 2
Liquibase case study
Liquibase – a time machine for your data
Successful DB migrations with Liquibase
Liquibase - Open Source version control for your database
Agile Database Development with Liquibase
Ad

Viewers also liked (8)

PPTX
Adi Sapir ISUG 123 11/10/2012
PPTX
DAC 2012
PPTX
Query handlingbytheserver
PPTX
Sql server user group news january 2013
PPTX
Things you can find in the plan cache
PPTX
Board retreat pwpt template
PDF
6 sql explorer - powershell dba
PDF
Windows azure sql_database_security_isug012013
Adi Sapir ISUG 123 11/10/2012
DAC 2012
Query handlingbytheserver
Sql server user group news january 2013
Things you can find in the plan cache
Board retreat pwpt template
6 sql explorer - powershell dba
Windows azure sql_database_security_isug012013
Ad

Similar to Dbcc.doc (20)

PPTX
Copy Data Management for the DBA
DOC
Oracle dba interview question
PPT
Remote DBA Experts 11g Features
DOCX
Oracle Database 12c "New features"
PPTX
Denver SQL Saturday The Next Frontier
DOC
Sql server
PDF
Rise of NewSQL
PPTX
Big Data Analytics Module-3 as per vtu syllabus.pptx
DOC
Sql server-dba
DOCX
Db2 Important questions to read
PDF
DB2 LUW V11.1 CERTIFICATION TRAINING PART #1
PDF
Oracle RAC 12c and Policy-Managed Databases, a Technical Overview
PPT
DB2UDB_the_Basics Day2
PPTX
PostgreSQL Terminology
DOCX
Sql data shrink steps
PPTX
Building scalable application with sql server
PDF
21 Pdfsam
PDF
PDF
MySQL 8 Server Optimization Swanseacon 2018
PDF
MySQL 8 Tips and Tricks from Symfony USA 2018, San Francisco
Copy Data Management for the DBA
Oracle dba interview question
Remote DBA Experts 11g Features
Oracle Database 12c "New features"
Denver SQL Saturday The Next Frontier
Sql server
Rise of NewSQL
Big Data Analytics Module-3 as per vtu syllabus.pptx
Sql server-dba
Db2 Important questions to read
DB2 LUW V11.1 CERTIFICATION TRAINING PART #1
Oracle RAC 12c and Policy-Managed Databases, a Technical Overview
DB2UDB_the_Basics Day2
PostgreSQL Terminology
Sql data shrink steps
Building scalable application with sql server
21 Pdfsam
MySQL 8 Server Optimization Swanseacon 2018
MySQL 8 Tips and Tricks from Symfony USA 2018, San Francisco

Recently uploaded (20)

PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPT
Teaching material agriculture food technology
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
KodekX | Application Modernization Development
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Cloud computing and distributed systems.
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Encapsulation theory and applications.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
sap open course for s4hana steps from ECC to s4
PPTX
Spectroscopy.pptx food analysis technology
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Teaching material agriculture food technology
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
KodekX | Application Modernization Development
Unlocking AI with Model Context Protocol (MCP)
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Spectral efficient network and resource selection model in 5G networks
Per capita expenditure prediction using model stacking based on satellite ima...
Cloud computing and distributed systems.
The AUB Centre for AI in Media Proposal.docx
MIND Revenue Release Quarter 2 2025 Press Release
Review of recent advances in non-invasive hemoglobin estimation
Dropbox Q2 2025 Financial Results & Investor Presentation
Advanced methodologies resolving dimensionality complications for autism neur...
The Rise and Fall of 3GPP – Time for a Sabbatical?
Encapsulation theory and applications.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
sap open course for s4hana steps from ECC to s4
Spectroscopy.pptx food analysis technology

Dbcc.doc

  • 1. 1.DBCC CHECKALLOC DBCC CHECKALLOC checks page usage and allocation in the database. Use this command if allocation errors are found for the database. If you run DBCC CHECKDB, you do not need to run DBCC CHECKALLOC, as DBCC CHECKDB includes the same checks (and more) that DBCC CHECKALLOC performs. 2.DBCC CHECKCATALOG This command checks for consistency in and between system tables. This command is not executed within the DBCC CHECKDB command, so running this command weekly is recommended. 3.DBCC CHECKCONSTRAINTS DBCC CHECKCONSTRAINTS alerts you to any CHECK or constraint violations. Use it if you suspect that there are rows in your tables that do not meet the constraint or CHECK constraint rules. 4.DBCC CHECKDB A very important DBCC command, DBCC CHECKDB should run on your SQL Server instance on at least a weekly basis. Although each release of SQL Server reduces occurrences of integrity or allocation errors, they still do happen. DBCC CHECKDB includes the same checks as DBCC CHECKALLOC and DBCC CHECKTABLE. DBCC CHECKDB can be rough on concurrency, so be sure to run it at off-peak times. 5.DBCC CHECKTABLE DBCC CHECKTABLE is almost identical to DBCC CHECKDB, except that it is performed at the table level, not the database level. DBCC CHECKTABLE verifies index and data page links, index sort order, page pointers, index pointers, data page integrity, and page offsets. DBCC CHECKTABLE uses schema locks by default, but can use the TABLOCK option to acquire a shared table lock. CHECKTABLE also performs object checking using parallelism by default (if on a multi-CPU system). 6.DBCC CHECKFILEGROUP DBCC CHECKFILEGROUP works just like DBCC CHECKDB, only DBCC CHECKFILEGROUP checks the specified filegroup for allocation and structural issues. If you have a very large database (this term is relative, and higher end systems may be more apt at performing well with multi-GB or TB systems ) , running DBCC CHECKDB may be time-prohibitive. If your database is divided into user defined filegroups, DBCC CHECKFILEGROUP will allow you to isolate your integrity checks, as well as stagger them over time. 7.DBCC CHECKIDENT DBCC CHECKIDENT returns the current identity value for the specified table, and allows you to correct the identity value if necessary. 8.DBCC DBREINDEX If your database allows modifications and has indexes, you should rebuild your indexes on a regular basis. The frequency of your index rebuilds depends on the level of database activity, and how quickly your database and indexes become fragmented. DBCC DBREINDEX allows you to rebuild one or all indexes for a table. Like DBCC CHECKDB, DBCC CHECKTABLE, DBCC CHECKALLOC, running DBREINDEX during peak activity times can significantly reduce concurrency. 9.DBCC INDEXDEFRAG Microsoft introduced the excellent DBCC INDEXDEFRAG statement beginning with SQL Server 2000. This DBCC command, unlike DBCC DBREINDEX, does not hold long term locks on indexes. Use DBCC INDEXDEFRAG for indexes that are not very fragmented, otherwise the time this operation takes will be far
  • 2. longer then running DBCC DBREINDEX. In spite of it's ability to run during peak periods, DBCC INDEXDEFRAG has had limited effectiveness compared to DBCC DBREINDEX (or drop/create index). 10.DBCC INPUTBUFFER The DBCC INPUTBUFFER command is used to view the last statement sent by the client connection to SQL Server. When calling this DBCC command, you designate the SPID to examine. (SPID is the process ID, which you can get from viewing current activity in Enterprise Manager or executing sp_who. ) 11.DBCC OPENTRAN DBCC OPENTRAN is a Transact-SQL command that is used to view the oldest running transaction for the selected database. The DBCC command is very useful for troubleshooting orphaned connections (connections still open on the database but disconnected from the application or client), and identification of transactions missing a COMMIT or ROLLBACK. This command also returns the oldest distributed and undistributed replicated transactions, if any exist within the database. If there are no active transactions, no data will be returned. If you are having issues with your transaction log not truncating inactive portions, DBCC OPENTRAN can show if an open transaction may be causing it. 12.DBCC PROCCACHE You may not use this too frequently, however it is an interesting DBCC command to execute periodically, particularly when you suspect you have memory issues. DBCC PROCCACHE provides information about the size and usage of the SQL Server procedure cache. 13.DBCC SHOWCONTIG The DBCC SHOWCONTIG command reveals the level of fragmentation for a specific table and its indices. This DBCC command is critical to determining if your table or index has internal or external fragmentation. Internal fragmentation concerns how full an 8K page is. When a page is underutilized, more I/O operations may be necessary to fulfill a query request than if the page was full, or almost full. External fragmentation concerns how contiguous the extents are. There are eight 8K pages per extent, making each extent 64K. Several extents can make up the data of a table or index. If the extents are not physically close to each other, and are not in order, performance could diminish. 14.DBCC SHRINKDATABASE DBCC SHRINKDATABASE shrinks the data and log files in your database. Avoid executing this command during busy periods in production, as it has a negative impact on I/O and user concurrency. Also remember that you cannot shrink a database past the target percentage specified, shrink smaller than the model database, shrink a file past the original file creation size, or shrink a file size used in an ALTER DATABASE statement. 15.DBCC SHRINKFILE DBCC SHRINKFILE allows you to shrink the size of individual data and log files. (Use sp_helpfile to gather database file ids and sizes). 16. DBCC TRACEOFF, TRACEON, TRACESTATUS Trace flags are used within SQL Server to temporarily enable or disable specific SQL Server instance characteristics. Traces are enabled using the DBCC TRACEON command, and disabled using DBCC TRACEOFF. DBCC TRACESTATUS is used to displays the status of trace flags. You'll most often see TRACEON used in conjunction with deadlock logging (providing more verbose error information). 17.DBCC USEROPTIONS Execute DBCC USEROPTIONS to see what user options are in effect for your specific user connection. This
  • 3. can be helpful if you are trying to determine if you current user options are inconsistent with the database options.