youwei 发表于 2011-03-16 22:14

在于BCP备份时报错!

系统:windows xp
数据库:sybase 11.9

小弟的数据库,可能是断电关机,损坏了,在重启数据库后,数据库报已经“置疑”,
我通过执行:
sp_configure "allow updates",1
        go
        reconfigure with override
        go
        update master..sysdatabases
        set status=-32768
        Where name="testdb"
        go
        shutdown with nowait
        go
在重启后,testdb库可以查询了,在用bcp 进行数据备份,想重新建库,但是在
bcp时,有许多表,并没有导出完成,在最后面出现了相似的错误如下:

其中一个表
。。。
29000 rows successfully bulk-copied to host-file.
30000 rows successfully bulk-copied to host-file.
31000 rows successfully bulk-copied to host-file.
Server Message:- Msg 695, Level 21, State 1:
An attempt was made to read logical page '1025232' for object '800057936' in database '5' from disk. Wrong logical page '1537232' was brought into cache 'default data cache'.

Server Message:- Msg 5702, Level 10, State 1:
The SQL Server is terminating this process.

另一个表
。。。
Starting copy...
1000 rows successfully bulk-copied to host-file.
2000 rows successfully bulk-copied to host-file.
Server Message:- Msg 695, Level 21, State 1:
An attempt was made to read logical page '1024048' for object '280388068' in database '5' from disk. Wrong logical page '1536048' was brought into cache 'default data cache'.

Server Message:- Msg 5702, Level 10, State 1:
The SQL Server is terminating this process.

我观察了下,发现,都是发生在第“5”号数据设备上,是不是,5号数据库设备有问题了呢!
在这个情况下,有办法修复吗?
请各位多多指教,谢谢!

hobbylu 发表于 2011-03-17 08:17

如果数据不重要,那么可以将这两个相关的表drop掉,重新建后可以解决。
重要的话,需要一定的技术处理,有一定的难度。把那些没有导出来的数据导出来。

youwei 发表于 2011-03-19 23:58

谢谢,回复!
请教,像这样的情况,想找回记录,应该怎么入手呢?
需要用什么工具来协助吗?
谢谢,请指教!

hobbylu 发表于 2011-03-20 09:42

在没有工具的情况下,可以通过修改sysindexes的first,root来拯救数据。
工具的话,可以用sybedit(sybase的官方,但已经没有提供)
powersybedit等

youwei 发表于 2011-03-20 21:27

哦,请教,修改,系统表的这个字段,有一些什么方式呢?
有什么依具呢!(不知道问的问题是不是大了点?)

hobbylu 发表于 2011-03-21 09:41

(1) isql -Usa -P to log into sql server and enter following commands
1> sp_role "grant","sybase_ts_role",sa
2> go
1>quit
2>go
(2) relogin into sql server with sa
(3) enter these commands in isql:
1> use your_database
2 > go
1> select first ,root ,indid from sysindexes
2> where id=object_id("table_name")
3>go
choose a line from the output of which the indid is neither 0 nor 1,
and pick up the value of its root. this is the root page number
of this index btree,next we will use root_page_number
to represent it and indid for its index id.
(4) find a page number which is on the data pages chain
1>dbcc prtipage(database_name,table_name, indid,root_page_number)
2>go
(4.1) read the last line of this dbcc output ,it is like:
index row at offset XX points to page XXXX.
take the page number xxxx and issue above command again :
1>dbcc prtipage(database_name,table_name,indid,XXXX)
2>go
repeat this step until the dbcc output looks like this:
leaf row at offset xxxxx points to data page nnnnn,row number xxxx.
this meens that we reach the leaf-level pages of this index btree,
so you choose a line from its output and read out the
page number, which is a data page of this table.
(5) from the data page (nnnn), you walk along the data page chain of this table
until we get to the begin, the first page of its database chain.
1>dbcc pglinkage(supportdb,nnnn,0,2,0,0)
2>go
the last number of this page number list is the first
page of this table. make sure the object id displayed is correct.
(6) update the first column of this table in sysindexes
1>update sysindexes set first=new_first_page where id=object_id('table_name')
2> and indid=0
3>go
(7) use select count(*) from table_name to test our work.
(8) select * into new_table from table_name.
(9) drop the old corrupt table.

youwei 发表于 2011-03-21 22:27

前辈,你好,谢谢你的指教:
我在看到
(4) find a page number which is on the data pages chain
1>dbcc prtipage(database_name,table_name, indid,root_page_number)
2>go
这步的时候,不明白:root_page_number
这参数是什么意思呢?从哪里读取的呢?

andkylee 发表于 2011-03-22 09:09

root_page_number 就是root列的值。 表示树根的页号。
页: [1]
查看完整版本: 在于BCP备份时报错!