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