- 論壇徽章:
- 0
|
錯(cuò)誤原始信息(例子):
An attempt was made to fetch logical page '%ld' in
database '%.*s' from cache '%.*s'. Page belongs to
object with id '%ld', not to object '%.*s'.
-------------------------------------------------------------------------------------------------
使用dbcc tablealloc 去檢查出現(xiàn)錯(cuò)誤的表
命令格式:
dbcc tablealloc('錯(cuò)誤信息中第二個(gè)表對(duì)象')
最好將錯(cuò)誤結(jié)果使用 isql 的 -o 參數(shù)輸出到文件中便于察看
注意:
這個(gè)dbcc 操作可能會(huì)鎖住接受檢查的表,這將影響到其他進(jìn)程的訪問(wèn)和操作。
-------------------------------------------------------------------------------------------------
DBCC 結(jié)果(例子為正常結(jié)果):
The default report option of OPTIMIZED is used for this run.
The default fix option of NOFIX is used for this run.
***************************************************************
TABLE: Tablename OBJID = id_number
INDID=1 FIRST=257 ROOT=264 SORT=0
Data level: 1. 1 Data pages allocated and 1 Extents allocated.
Indid : 1. 1 Index pages allocated and 1 Extents allocated.
INDID=2 FIRST=272 ROOT=272 SORT=0
Indid : 2. 1 Index pages allocated and 1 Extents allocated.
TOTAL # of extents = 3
Alloc page 256 (# of extent=1 used pages=2 ref pages=2)
Alloc page 256 (# of extent=1 used pages=3 ref pages=3)
Alloc page 256 (# of extent=1 used pages=2 ref pages=2)
Total (# of extent=3 used pages=7 ref pages=7) in this database
DBCC execution completed. If DBCC printed error messages, contact a user with System Administrator (SA) role.
-------------------------------------------------------------------------------------------------
一.
如果有一些錯(cuò)誤(例如2583或者其他)出現(xiàn)在 INDID為0之后,表示表本身數(shù)據(jù)損壞。
解決辦法:
1. 使用 "select into" 或者 "insert into ... select " 將壞表中能夠正常訪問(wèn)的數(shù)據(jù)取出裝入一個(gè)臨時(shí)表中。同時(shí)可以使用
" where"加上一些可以縮小選擇范圍的條件盡量多的將正常的數(shù)據(jù)取出
2. 或者使用bcp去導(dǎo)出正常的數(shù)據(jù)
3. 對(duì)于實(shí)在無(wú)法取出的數(shù)據(jù),只能通過(guò)應(yīng)用系統(tǒng)中的冗余或者相關(guān)信息進(jìn)行恢復(fù)
4. 刪除或者重命名壞表,并重新創(chuàng)建新表
5. 將導(dǎo)出的正常數(shù)據(jù)重新導(dǎo)入新表中
注意: 可能會(huì)有一些數(shù)據(jù)的丟失
-------------------------------------------------------------------------------------------------
二.
如果有一些錯(cuò)誤(例如2583或者其他)出現(xiàn)在 INDID為1之后,說(shuō)明表上的聚簇索引損壞,解決方法同一,也可能出現(xiàn)數(shù)據(jù)丟失。
如果有一些錯(cuò)誤(例如2583或者其他)出現(xiàn)在 INDID為2,3,4.....之后,說(shuō)明為表上的非聚簇索引損壞,解決方法比較簡(jiǎn)單,刪除此索引然后重新創(chuàng)建即可。
步驟如下:
1. use databasename
go
2. 獲知索引名稱(chēng)
select name from sysindexes where id = table_object_id and indid = index_number
go
3. 創(chuàng)建一個(gè)跟壞索引不同名稱(chēng)但具有相同列的索引
create index
你可以使用 sp_help table_name 去察看索引上的列信息
4. 將已損壞索引刪除
drop index
-------------------------------------------------------------------------------------------------
當(dāng)這些故障排除完畢后,有時(shí)間及業(yè)務(wù)系統(tǒng)允許的情況下,最好再做一次全庫(kù)的dbcc檢查
DBCC checkdb(db_name)
DBCC checkalloc(db_name)
DBCC checkcatalog(db_name) |
|