1. 程式人生 > >sybase :資料庫不能開啟的解決辦法(狀態裝載或可疑)

sybase :資料庫不能開啟的解決辦法(狀態裝載或可疑)

 平臺資料:
作業系統平臺:Windows 2000 5.00.2195 Service Pack 4
資料庫平臺:Sysbase 12.5
server:db_jc,database:db_text,db_jd,db_jh,db_app
現象:
整個伺服器正常執行,此伺服器上的db_jd,db_jh執行正常,只有db_text不能開啟(提示狀態為裝載或可疑狀態)。
用Powerbuilder 6.0連線時報
Database 'db_jc' cannot be opened. An earlier attempt at recovery marked it 'suspect'. Check the SQL Server errorlog
for information as to the cause.
檢視錯誤日誌errorlog,發現有這麼一段:
Keys of index id 1 for table 'systhresholds' in data page not in correct order. Drop and re-create the index. (index
page 337)
The total number of data pages in this table is 1.
Table has 2 data rows.
DBCC execution completed. If DBCC printed error messages, contact a user with System Administrator (SA) role.
分析:
資料庫重新啟動的時候報錯,該應用資料庫不能online,無法訪問該資料庫上的應用資料。
解決辦法:
查手冊的表述入下
  Table 'systhresholds' in database '%.*s' is not in its
    correct sort order. Either the clustered index is
    missing or there is data corruption in the table.
和日誌中表述一樣,按照提示,執行dbcc
錯誤資訊如下:
    Keys of index id 1 for table 'systhresholds' in data page not in correct order. Drop and re-create the index. (index page
337)
The total number of data pages in this table is 1.
Table has 2 data rows.
DBCC execution completed. If DBCC printed error messages, contact a user with System Administrator (SA) role.
最後的解決辦法是:
isql -Usa -P************ -Sdb_jc 進入isql環境  (後面帶備註)
  use master
  go
  dump database master to "/usr/sybase/master.dup"  --備份master資料庫
  go
  sp_configure "allow updates", 1    --允許sysdatabases可以被修改
  go
  update sysdatabases set status = -32768 where name = 'db_text'    --狀態標誌修改
  go
  update sysdatabases set status2 = -32768 where name = 'db_text'
  go
  shutdown --伺服器關閉
  go
  use db_text
  go
  select first from sysindexes where id = object_id("systhresholds")  --獲取索引頁
  go
  select count(*) from systhresholds  --獲取資料行
  go
  dbcc traceon(3604)
  go
  dbcc delete_row('db_text',337;, row, 0) --刪除壞行
  go
  dbcc delete_row('db_text',337, row, 1)
  go
  select count(*) from systhresholds --檢查
  go
  use master
  go
  update sysdatabases set status = 0 where name = 'db_text'  --標誌復位
  go
  update sysdatabases set status2 = 0 where name = 'db_text'
  go
  sp_configure "allow updates", 0  --不允許sysdatabases可以被修改
  go
  shutdown with nowait
  go
  此時啟動正常了。。做dbcc檢查,沒有報錯!