Introduction to Sybase, Part 1: Setting Up the Server

Sybase comes to Linux—here's how it works.
Testing the Server

There is a basic client that comes with the Sybase SQL Server. This program is called isql. It is an interactive SQL program that allows you to enter SQL commands to the server and see the results. At the command line, type:

isql -Usa -Slinux_dev

The -U option tells the isql program which user name to use; sa is the system administrator account. It is similar to root on Linux. It has all rights in the server. The -S option specifies to which server to connect. In our case, the server name is linux_dev. The isql program will ask you for a password. Right after an installation, the sa user does not have a password, so just press enter. You can now enter SQL commands that will run on your SQL server.

The first command to run is a stored procedure that lets you change the password of a user. At the 1> prompt, type

sp_password null,'

sp_password is the name of the stored procedure. The sa user has no password, so we pass null as the first parameter. This parameter should be the password of the current user. The second parameter is the new password; put this password in quotes.

At the 2> prompt, type:

go

go tells the isql program to execute the command. If you make a mistake while typing a command before typing go, you can type reset to erase the command and try again.

All of the configuration information for the SQL server is stored in tables in the master database. Type the following:

1> select name from sysdatabases
2> go

This is an SQL command that queries the sysdatabases table. It will list the names of all the databases in your server. Almost all of the configuration information for the SQL server is stored in database tables. The documentation will give you more information on these tables.

To quit the isql program, type quit at the 1> prompt.

The SQL server comes with a script that will install an example database on your server. To install this database, type the following command at the $ prompt:

sql -Usa -i ~sybase/scripts/installpubs2 \
   -Slinux_dev

Type your new password when prompted. The script will create a database called pubs2, then create tables with data in them. You can now type queries like the following:

isql -Usa -Slinux_dev
Password:
1> use pubs2
2> go
1> select * from authors
2> go
au_id  au_lname    ...
----------- ------------------- ...
172-32-1176 White    ...
213-46-8915 Green    ...
...
1> quit

Shutting Down the Servers

Before you shut down your Linux system, you should shut down your Sybase servers. Do this using the isql program. Log in as the sa user to shut down the server. Once you are in isql, type shutdown SYB_BACKUP to shut down the backup server. SYB_BACKUP is the default name for a backup server. Then type shutdown to shut down the SQL server; this will remove both servers from memory. Now you can shut down your Linux system. If you don't shut down the servers properly, you could corrupt data. I recommend writing a script to perform this task automatically.

Starting the Servers

To start up the servers, you need to be logged in as the user sybase. Change to the install directory and type:

 ./startserver -f ./RUN_linux_dev

to start the SQL server and then

 ./startserver -f
./RUN_linux_dev_bs
to start the backup server. A startup script named /etc/rc.d/init.d/sybase is installed on your system. You can link this script to the proper places in your rc.d directories so the server will automatically start and stop when you start and stop your Linux system.

Conclusion

You have installed the SQL server and the backup server and you know how to start and stop it. There is still more to learn about the server. At the end of this article is a list of resources that can help you learn about your new Sybase SQL server. I recommend reading the PostScript documentation that comes with the server. If you don't want to print the hundreds of pages of documentation, you can use ghostscript to view them. For an easier way to view the documentation, go to http://sybooks.sybase.com/dynaweb and select Sybase Version 11.0.x Products. You can read all the documentation via Sybase's web site.

Next month's installment will be about writing database clients and installing the Sybase extension for Perl (sybperl) that will enable writing database clients in Perl.

Resources

Jay Sissom is responsible for the web-based front end to the financial decision support data at Indiana University. He has installed and supported Sybase databases on many operating systems and has written database clients for the Web using C, C++ and sybperl and for Windows using tools like Visual Basic and PowerBuilder. When he isn't programming, he enjoys amateur radio and playing his bass guitar and keyboards. If you have questions, you can contact him via e-mail at the address jsissom@indiana.edu.

______________________

White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState