Getting Started With Sybase

Index

General info

Before you start using sybase there are some very important things you need to know. First of all, if you have a CS Grad UNIX account (paul/george/john) you are not necessarily entitled to a sybase account. Only students that are taking cs courses that require use of a database (e.g. 198:541) are entitled to a sybase account. Your sybase account can only be accessed from john

Your sybase account name and password will be different than your UNIX username and password. A typical sybase account name looks like this:

spr96db19

You may also be sharing your sybase account with other people in your group. People in your group will share the same sybase account name and same sybase password. Keep in mind that you should NEVER share your UNIX password with anyone under any circumstances

The main sybase area is in /usr/local/sybase. You will most likely be using
/usr/local/sybase/bin/isql
/usr/local/sybase/bin/apt
/usr/local/sybase/bin/dwb

Backing up your work

Since Sybase does not use a regular UNIX filesystem to store its data, we don't perform regular backups on it. For this reason you need to back up your information regularly (see below). If something goes wrong, and you database is corrupted or lost, we will not be able to do a restore for you.
1> dump database spr96db19 to "/tmp/spr96db19.dump"
2> go
Backup Server session id is:  11.  Use this value when executing the
'sp_volchanged' system stored procedure after fulfilling any volume change
request from the Backup Server.
Backup Server: 4.41.1.1: Creating new disk file /tmp/spr96db19.dump.
Backup Server: 6.28.1.1: Dumpfile name 'spr96db191990AC34' section number 0001
mounted on disk file '/tmp/spr96db19.dump'
Backup Server: 4.58.1.1: Database spr96db19: 238 kilobytes DUMPed.
Backup Server: 3.43.1.1: Dump phase number 1 completed.
Backup Server: 3.43.1.1: Dump phase number 2 completed.
Backup Server: 4.58.1.1: Database spr96db19: 242 kilobytes DUMPed.
Backup Server: 3.43.1.1: Dump phase number 3 completed.
Backup Server: 4.58.1.1: Database spr96db19: 246 kilobytes DUMPed.
Backup Server: 3.42.1.1: DUMP is complete (database spr96db19).
1> quit
john 2>cp /tmp/spr96db19.dump ~/071296.dump
john 2>rm /tmp/spr96db19.dump
Obviously you will need to copy it to give today's date rather than 071296, and dump your own database rather than spr96db19.

Here is a sample session of restoring your database from a backup file:

1> use master
2> go
1> load database spr96db19 from "/grad/u/ledzian/071296.dump"
2> go
Backup Server session id is: 16.
Use this value when executing the 'sp_volchanged' system stored
procedure after fulfilling any volume change request from the Backup
Server.  Backup Server: 6.28.1.1: Dumpfile name ' spr96db1990AC34'
section number 0001 mounted on disk file '/grad/u/ledzian/071296.dump'
Backup Server: 4.58.1.1: Database spr96db19: 2052 kilobytes LOADed.
Backup Server: 4.58.1.1: Database spr96db19: 2060 kilobytes LOADed.
Backup Server: 3.42.1.1: LOAD is complete (database spr96db19).  Use
the ONLINE DATABASE command to bring this database online; SQL Server
will not bring it online automatically.
1> online database spr96db19
2> go
Database 'spr96db19' is now online.
1> use spr96db19
2> go
We don't recomend that you try to restore your database unless you really need to. And even then you may want to contact us via email at help@paul first.

Changing your Password

Your professor/TA will assign your sybase account name and sybase password. The first thing you should do is change your password. To change your sybase password run:

/usr/local/sybase/bin/isql -SGR -Uusername
where username is the sybase username that was given to you by your professor. Onces in isql, use sp_passwd oldpass, newpass

Here is a sample session:

john 2> /usr/local/sybase/bin/isql -SGR -Uspr96db19
Password: 
1> sp_password spr96db19, secret
2> go
Password correctly set.
(return status = 0)
1> quit
john 2> 

Setting ENV variables

There are an number of enviornment variables you need to set in order for sybase to work properly. You can put these commands in your .cshrc

#for sybase;
setenv DSQUERY GR

#for sybooks;
setenv SYBASE /usr/local/sybase
setenv SYBROOT /usr/local/sybase/sybooks
setenv EBTRC /usr/local/sybase/sybooks/sun5mol/.ebtrc

#for apt forms
setenv SYBFORMLIST <some directory in your homedir>

Note that you will have to logout and log back in for your changes in .cshrc to take effect

What documentation is available for Sybase?

There is a full set of Sybase documentation available online. You can access it on the machines that have the Sybase server installed with the following two commands:

How do I use JDBC and jConnect to interface Sybase?

You can use java applets to access your sybase databases. Documentation can be found in both HTML format and PDF format
Here is a sample of what is possible. Be sure that you do not set your classpath for this to work.

The log segment in my database is full. What do I do?

This means exactly what it says. You only have a fixed size log transaction segment, and it is full. You can dump your transaction log with the following command:
dump transaction mydatabase with no_log
where mydatabase is the name of your database.