Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which type of repair level is "DBCC CHECKDB (databasename, repair)"?

The MSDN's article about the command "DBCC CHECKDB" explains three ways to perform a database repair in the syntax section:

- REPAIR_ALLOW_DATA_LOSS
- REPAIR_FAST
- REPAIR_REBUILD

But I found the following statement when I was looking for how to repair a suspect database and I can't understand which one of the three modes is it:

DBCC CHECKDB (databaseName, repair)

I executed the statement and it works fine. I'm confused because there isn't any reference to the "repair" parameter alone without finish the word with "_allow_data_loss", "_fast" or "_rebuild".

Thanks in advance,

like image 213
agdiaz Avatar asked Dec 16 '15 14:12

agdiaz


People also ask

What is DBCC Checkdb for?

Checks the logical and physical integrity of all the objects in the specified database by performing the following operations: Runs DBCC CHECKALLOC on the database. Runs DBCC CHECKTABLE on every table and view in the database. Runs DBCC CHECKCATALOG on the database.

Is DBCC Checkdb resource intensive?

DBCC CHECKDB is one of the most preferred security check available in SQL Server, for running on your databases, it is a resource intensive practice, that is why the regularity of these checks differs with different organizations. This is one of the best ways to check for corruption in SQL Server databases.

Is DBCC Checkdb an online operation?

Answer: Yes, it is true that from SQL Server 2000 onwards, DBCC CHECKDB runs online by default. Even in SQL Server 2000 though, DBCC CHECKDB still took Schema-Stability locks on tables that were being checked as it could not cope with their metadata changing during a running consistency check.

How do I fix DBCC Checkdb consistency errors?

The best solution if DBCC CHECKDB reports consistency errors is to restore from a known backup. See Restore and Recovery for more information. If it isn't possible to restore from a backup, CHECKDB has a feature to repair errors.


1 Answers

Specifying only "repair" as the second parameter in DBCC CHECKDB will be the same as "repair_allow_data_loss". I just ran this on a local instance, and the SQL logs confirm this.

like image 81
Jeffrey Van Laethem Avatar answered Oct 05 '22 22:10

Jeffrey Van Laethem