After the database corruption in Sybase database management system, the time to re-establish the database is longer, which will cause great loss to the application (especially the application of strict time requirement, such as finance, securities, etc.). And if you forget the Super User sa password in the application, it will bring great inconvenience to system management, even many operations can not be carried out. This article describes an easy way to repair the Sybase database and recover the sa password. The following assumes that the server will start normally, with the server named Sybase and the database named Demodb.
First, the restoration of Sybase database is divided into two situations:
1. The equipment used by the database is normal, and the DEMODB state of the library is suspect.
(1) registered with SA
isql -u sa -P
1>
(2) Modify the server property to allow the system table to modify the state.
1>sp_configure "allow updates",1
2>go
3>recofigure with override
4>go
(3) Modify the state of the database, do not detect when the database state is started by server.
1>update master.sysdatabases set status = -32768
2>where name = "demodb"
3>go
(4) Restart server.
(5) Modify the state of the database, and set the database status to normal.
1>update master.sysdatabases set status = 0
2>where name ="demodb"
3>go
(6) Modify the server property to place the system table as not allowed to modify the state.
1>sp_configure "allowupdates",0
2>go
3>reconfigure with override
4>go
(7) Reboot the server again.
At this point, if the database is functioning correctly, the recovery is complete.
In the previous steps, you can also start the server in Single-user mode, and the command is startserver-m without having to modify the server's allow updates property. The SYBASE 11 and above versions of the server only need to be restarted and do not require reconfigure with override. If the above method still fails to recover the database, you can only delete the database using the DBCC command and then re-establish it.
2. The database occupies the device is not normal, the state of the library for suspect use sp_helpdb and sp_helpdevice command to detect the database device logical name, physical name, device number, size, and other information. If the above command does not detect database device information, you can use the SELECT * from Master.sydatabases and select * from Master.sysdevices. Then use disk Reinit to reconstruct the equipment. Finally, follow the steps in 1 to restore the database.
The first of the above situation database damage is lighter, the database content can be used after inspection. And in the second case, if the database log is built on different devices, only the database log device is corrupted, the database is less damaged, only some transactions cannot be recovered, and if the database's device is corrupted, the entire database is lost, and the contents of the table, table, and stored procedures need to be rebuilt. Therefore, it is recommended that databases and database logs be built on different devices.
System error log errorlog file contains the Sybase database system error message, system error should first check this file, to judge the cause of the error, to find solutions to avoid misoperation.
Second, recover the sa password
Edit Run_sybase, add parameter-psa at dataserver start line, and then save and exit, execute startserver-f run_sybase Restart server, the system will give Superuser sa a random password to register into the server with this password , and then use the sp_password command to modify the password.