Sybase

For generic SQL see the database mainpage

sp_helpdb
Show all databases
sp_help
Show all objects in the current database
select name,id,loginame,type from sysobjects where type = ‘U’
Show only the user tables in the currect database
bcp <table> out <file> -c -U<user> -P<passwd> -S<engine>
Bulk copy out. Copy the data in <table> to <file> as character strings.
bcp <table> in <file> -c  -U<user> -P<passwd> -S<engine>
Put the data in <file> in <table>. <file> must have the correct structure to match <table> (first do a bcp out to be sure about the file-format).

Rebuild Sybase (still to be checked on a real system)

Make sure you have a printout from sp_helpdevice

# lvcreate -C y -L <MBs> -n <devname> -m 1 -s g <volgroup>
Create raw device (HP-UX LVM) with size <MBs> and one mirror in volume group <volgroup>

Clean install of Sybase server

# rm -f /var/sybase/rdsk*
# cd &ltsybase installation direcotry>
# ./SybaseInstall.sh deinstall # ./SybaseInstall.sh
Install Sybase server. Change parameters for sa password and the devices to install (add devices if necessary)
isql> shutdown
isql> go
Stop Sybase server
# cd /opt/sybase/server/install/RUN_SQL_<Servername>
isql>load database master from “<dumpfile>”
isql> go
This loads the master database and ends with the shutdown of the sybase server.
# /sbin/init.d/SQL<Servername> stop
# /sbin/init.d/SQL<Servername> start
Restart the database in multiuser mode.
isql> load database sybsystemprocs from “<dumpfile>”
isql> go
isql>online database sybsystemprocs
isql>go
Continue with repairing the user databases

Master database is still there but userdatabase’s are corrupted

Make sure you have a printout from sp_helpdb <database> for all databases.

isql> use master
isql> go
isql> dbcc dbrepair (<database>,dropdb)
isql> go
isql> create database <database> on <datadevice> = <data-size> log on <logdevice> = <log-size> for load
isql> go
isql> load database <database> from “<dumpfile>”
isql> go
isql> online database
isql> go
isql> use <database>
isql> go
isql> sp_changedbowner <dbowner>
isql> go
That’s it

 

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.