Introduction to Sybase, Part 1: Setting Up 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 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 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
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.
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_bsto 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.
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.
- September 2014 Issue of Linux Journal: HOW-TOs
- [<Megashare>] Watch Mrs Brown's Boys Movie Online Full Movie HD 2014
- Tech Tip: Really Simple HTTP Server with Python
- Considering Legacy UNIX/Linux Issues
- Memory Ordering in Modern Microprocessors, Part I
- Cluetrain at Fifteen
- RSS Feeds
- Security Hardening with Ansible
- New Products
- Getting Good Vibrations with Linux