Sybase 資料庫發生 Error: 644, Severity: 21, State: 1

通常此錯誤都是 索引損毀造成,在非資料庫伺服器等級機器上容易出現,官方說法通常是硬體問題引起,但實際狀況不一定。

Error: 644, Severity: 21, State: 1

後通常還會接這樣訊息:

Index row entry for data row id (11316867, 0) is missing from index page 11405926 of index id 5 of table 'myTable' in database 'CURDB'. Xactid is (7099705,6). Drop and re-create the index.

雖然官方說法建議使用 dbcc checktable 或是 sp_fixindex 來處理,但是效果不理想,建議還是重建比較好。

但是怎麼知道錯誤是哪個索引檔呢?

先用 sysindexes 列出全部索引


select si.*
from sysindexes si,sysobjects so
where so.id = si.id
and so.type = 'U'
and so.name = 'myTable'
go


然後錯誤訊息指名 index id 5 ,所以找到欄位 indid 為 5 的索引名稱 'CUST_IDX'。

接下來就是 DROP 索引


drop index myTable.CUST_INDEX
go


再來重建,由於此索引不是主索引所以下面使用 nonclustered 建立


create nonclustered index CUST_IDX
on dbo.myTable (column1,column2,column3....)
on 'default'
go


※如果該資料表資料量很大,依照機器速度可能會花上半天左右。

參考:
How to find Index List in a Sybase database?
Error 644 - Sybase Infocenter

留言

這個網誌中的熱門文章

【研究】列印的條碼為什麼很難刷(掃描)

C# 使用 Process.Start 執行外部程式

統一發票列印小程式