DBCC CHECKDB logging

Chaitanya Kiran 801 Reputation points
2023-01-24T17:11:53.9033333+00:00

Is DBCC CHECKDB logged operation?

SQL Server Other
0 comments No comments
{count} votes

Accepted answer
  1. Seeya Xi-MSFT 16,586 Reputation points
    2023-01-26T01:36:35.15+00:00

    Hi Chaitanya Kiran,

    What I am asking is plain and only DBCC CHECKDB command. Is it logged?

    No. I did it in my test database. There is no change in the transaction log before and after DBCC CHECKDB.

    Best regards,

    Seeya

    1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. Erland Sommarskog 121.4K Reputation points MVP Volunteer Moderator
    2023-01-24T22:29:30.9733333+00:00

    Plain DBCC CHECKDB is not, since it is not doing any updates. If you use any of the REPAIR options, yes it is. Or, well, I have not tested of verified, but anything else would be extremely remarkable, since if a non-logged operation is interrupted, your database is corrupt. (And in case of DBCC CHECKDB REPAIR, even more than it was before.)

    Generally, there are no non-logged operations in SQL Server.


  2. Seeya Xi-MSFT 16,586 Reputation points
    2023-01-25T06:14:51.21+00:00

    Hi Chaitanya Kiran,

    Please refer to this MS document: DBCC CHECKDB (Transact-SQL)

    You can read this article to know what DBCC CHECKDB is doing.

    DBCC CHECKDB 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.
    • Validates the contents of every indexed view in the database.
    • Validates link-level consistency between table metadata and file system directories and files when storing varbinary(max) data in the file system using FILESTREAM.
    • Validates the Service Broker data in the database.

    I find a link of corrupt database for you: https://www.sqlserverscience.com/tools/how-to-corrupt-a-database/

    I did this test. After I perform the destruction operation:

    User's image

    Then, I run DBCC CHECKDB with repair_allow_data_loss:

    User's image

    We check transaction log:

    User's image

    The number of transaction logs has changed, and you can see the operations.

    Best regards,

    Seeya


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.