Blog Post

What is DBCC?

,

DB Nuts and BoltsIf I ask you what is DBCC, what would your answer be?

I want you to think about that one for just a little bit. What comes to mind when you hear DBCC? Is it the default go-to used when talking about consistency checks? Is it something more involved? Maybe it is something entirely different?

I ponder this because I hear it from time to time used in complete replacement for CheckDB. I have to stop and think for a minute because as of SQL Server 2016, there are 35 DBCC statements of various use that are documented. Never-mind the bounty of un-documented statements (e.g. page, ind).

So, I ask, what does DBCC mean to you?

In trying to come up with some sort of answer, I did a little bit of research. If you look in the documentation (including the SQL 2000 documentation), one will find this definition for DBCC:

The Transact-SQL programming language provides DBCC statements that act as Database Console Commands for SQL Server.

It seems the documentation says it pretty clearly that DBCC is Database Console Commands. (And the SQL 2000 documentation says something similar). But every now and then you hear somebody say it means Database Consistency Checker. And it seems the root of that may come from the SQL 6.5 or earlier days. I found this snippet in BOL from SQL 6.5:

Used to check the logical and physical consistency of a database, check memory usage, decrease the size of a database, check performance statistics, and so on. DBCC is the SQL Server “database consistency checker.” DBCC helps ensure the physical and logical consistency of a database; however, DBCC is not corrective. It is recommended that you make periodic checks to ensure the logical and physical consistency of your data.

This seems a little odd to me since not all DBCC statements are used for database consistency checking as this definition would call it. It seems more of a documentation bug that has taken hold than a legitimate acronym. Just think about it. With that definition, one will also see a list of DBCC statements – many of which do not perform consistency checks. Let’s look at them:

DBCC {
CHECKALLOC [(database_name [, NOINDEX])] | 
CHECKCATALOG [(database_name)] | 
CHECKTABLE (table_name [, NOINDEX | index_id]) | 
CHECKDB [(database_name [, NOINDEX])] | 
CHECKIDENT [(table_name)] | 
DBREPAIR (database_name, DROPDB [, NOINIT]) | 
dllname (FREE) | 
INPUTBUFFER (spid) | 
MEMUSAGE | 
NEWALLOC [(database_name [, NOINDEX])] | 
OPENTRAN ({database_name} | {database_id}) 
[WITH TABLERESULTS] | 
OUTPUTBUFFER (spid) | 
PERFMON | 
PINTABLE (database_id, table_id) | 
SHOW_STATISTICS (table_name, index_name) | 
SHOWCONTIG (table_id, [index_id]) | 
SHRINKDB (database_name [, new_size [, 'MASTEROVERRIDE']]) | 
SQLPERF ({IOSTATS | LRUSTATS | NETSTATS | RASTATS [, CLEAR]} |
{THREADS} | {LOGSPACE}) | 
TEXTALL [({database_name | database_id}[, FULL | FAST])] | 
TEXTALLOC [({table_name | table_id}[, FULL | FAST])] | 
TRACEOFF (trace#) | 
TRACEON (trace#) |
TRACESTATUS (trace# [, trace#...]) | 
UNPINTABLE (database_id, table_id) | 
UPDATEUSAGE ({0 | database_name} [, table_name [, index_id]]) |
USEROPTIONS}

For instance, DBCC PINTABLE is hardly useful for checking consistency. The TRACESTATUS is also one that does not quite fit this acronym. That is likely why you will see the difference in the SQL 2000 and beyond documentation for DBCC.

Don’t be surprised if you hear me ask which DBCC statement is being inferred if I hear somebody say they ran DBCCs. It is just plain more clear to hear “CheckDB came up clean” over the alternative “DBCC came up clean”. There is little room for interpretation there.

In short, DBCC is an acronym for Database Console Command, and it seems more of a documentation mistake when it was called Database Consistency Checker.

Another interesting thought. How many people say DBCC Command(s)? Think about that one for a minute – Database Console Command Command(s). That one is less of an issue imho than the prior.

Just remember, think about what you mean to say when talking about a specific DBCC statement and if you really mean a consistency check, try saying CheckDB instead. I bet the clarity in the conversation will improve and there will be less hair tugging.

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating