An attempt to extract a logical page (1:1640) in database 5 failed. This logical page belongs to allocation unit xxx, not xxx. __ Database

Source: Internet
Author: User
An attempt to extract a logical page (1:1640) in database 5 failed. This logical page belongs to allocation unit xxx, not xxx.

article Category: Database This information indicates that the database or table is partially corrupted and can be tried by the following steps:
1. DBCC CHECKDB
After restarting the server, perform the following SQL database repairs in SQL Query Analyzer without doing anything, fixing the consistency errors and allocation errors in the database.

SQL code use Master declare @databasename varchar(255) set @databasename = ' Name of the database entity that needs to be repaired ' exec sp_dboption @databasename, n ' single ', n ' true '--set the target data base to Single-user State DBCC CHECKDB (@databasename, Repair_all Ow_data_loss) DBCC CHECKDB (@databasename, repair_rebuild) exec sp_dboption @databasename, n ' single ', N ' fal Se '--set the target data base to multiuser state

Use master 
declare @databasename varchar (255) 
Set @databasename = ' Name of the database entity that needs to be repaired ' 
exec sp_dboption @ DatabaseName, n ' single ', n ' true '--set target data base to single user state 
DBCC CHECKDB (@databasename, repair_allow_data_loss) 
DBCC CHECKDB (@databasename, repair_rebuild) 
exec sp_dboption @databasename, n ' single ', n ' false '--set target data base to multiuser state

Then perform the DBCC CHECKDB (the name of the database entity to be repaired) to check that the database is still in error. Note: The repair may result in some loss of data.
2. DBCC checktable
If the DBCC CHECKDB check still has errors, you can use DBCC CHECKTABLE to fix them.
SQL code use the name of the database entity that needs to be repaired Declare@dbname varchar(255) Set@dbname = ' Name of the database to be repaired ' execsp_dboption @dbname, ' Single user ', ' true ' DBCC CHECKTABLE (' The name of the data table to be repaired ', repair_allow_data_loss) DBCC CHECKTABLE (' requires The name of the repaired datasheet ', repair_rebuild '------Change the name of the ' data table to be repaired ' to the name of the data table that executes the DBCC CHECKDB times error execsp_dboption @dbname, ' Single user ', ' false '
Use the name of the database entity that needs to be repaired 
declare @dbname varchar (255) 
Set @dbname = ' Name of the database to be repaired ' 
exec sp_dboption @dbname, ' Single user ', ' true ' 
DBCC CHECKTABLE (' Name of data table to be repaired ', repair_allow_data_loss) 
DBCC CHECKTABLE (' name of the data table to be repaired ', Repair_rebuild) 
------Change the name of the ' data table to be repaired ' to the name of the data table that executes the DBCC CHECKDB times error 
exec sp_dboption @dbname, ' Single user ', ' False

3. Some of the other common repair commands
DBCC Dbreindex rebuilds one or more indexes of a table in the specified database
Usage:
The SQL code DBCC dbreindex (table name, ') fixes all indexes in this table.
DBCC dbreindex (table name, ') fixes all indexes in this table.

4.DBCC Checkalloc
Check the consistency of the disk space allocation structure for the specified database


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.