SQL DB无法修复

xizhi 1 Reputation point
2022-03-24T08:40:38.787+00:00

由于数据库不一致性,于是修复
用DBCC CHECKDB (数据库名, REPAIR_ALLOW_DATA_LOSS); 报错(如图):
”消息 8921,级别 16,状态 1,第 1 行

检查已终止。收集事实数据时检测到错误。可能是 tempdb 空间用尽或某个系统表不一致。请检查前面的错误消息。
186383-6.jpg

SQL Server | Other
{count} votes

1 answer

Sort by: Most helpful
  1. AmeliaGu-MSFT 14,011 Reputation points Microsoft External Staff
    2022-03-25T02:52:24.767+00:00

    Hi xizhi,

    Welcome to Microsoft Q&A.
    As error message mentioned, please make sure there is enough space on the drive that tempdb is on.
    You can use the sys.dm_db_file_space_usage dynamic management view to monitor the disk space that's used in the tempdb files:

    -- Determining the amount of free space in tempdb  
    SELECT SUM(unallocated_extent_page_count) AS [free pages],  
      (SUM(unallocated_extent_page_count)*1.0/128) AS [free space in MB]  
    FROM tempdb.sys.dm_db_file_space_usage;  
      
    -- Determining the amount of space used by the version store  
    SELECT SUM(version_store_reserved_page_count) AS [version store pages used],  
      (SUM(version_store_reserved_page_count)*1.0/128) AS [version store space in MB]  
    FROM tempdb.sys.dm_db_file_space_usage;  
      
    -- Determining the amount of space used by internal objects  
    SELECT SUM(internal_object_reserved_page_count) AS [internal object pages used],  
      (SUM(internal_object_reserved_page_count)*1.0/128) AS [internal object space in MB]  
    FROM tempdb.sys.dm_db_file_space_usage;  
      
    -- Determining the amount of space used by user objects  
    SELECT SUM(user_object_reserved_page_count) AS [user object pages used],  
      (SUM(user_object_reserved_page_count)*1.0/128) AS [user object space in MB]  
    FROM tempdb.sys.dm_db_file_space_usage;  
    

    According to this doc, please also try to run the DBCC CHECKDB with the TABLOCK option.

    Best Regards,
    Amelia


    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".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

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