Вы находитесь на странице: 1из 6

Document Viewer http://rkm.bmc.com/rkm/viewdoc.jsp?remedy=1&doc=KM-0000000115...

Print Close

Problem Details
Some commonly used SQL statements in support - Sybase ID: KM-000000011549
Product Type: Problem Solution

Environment

Solution
Starting Sybase: Most installations here are as root. You can check the owner of the files in the
$SYBASE directory to confirm the owner of the install. ***First, you'll need to set your environment
variables. Sybase provides .sh and .csh files for your convenience. You need to source these files as
you would either a .profile or .cshrc file (depending on your shell). Run either of these commands from
the Sybase home directory:

. ./SYBASE.sh (if you're in Bourne or Korn shell)

source SYBASE.csh (if you're in C shell)

next, cd to the $SYBASE/ASE-12_0/install or $SYBASE/ASE-12_5/install directory. There you'll find a


RUN_servername script. While Sybase recommends that you use a different command, you can start
Sybase by running the RUN_servername script. For example, if the Sybase server name is cruiser, use
RUN_cruiser script (be sure to start it in the background):

./RUN_cruiser &

(if you want to use the Sybase recommended way, use the startserver script (with the -f option)
located in the same directory as the RUN_servername script). Make sure you provide the full path to
the RUN_servername script. For example:

./startserver -f $SYBASE/ASE-12_0/install/RUN_cruiser &

Additional information on startup of Sybase database:


http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.help.ase_15.0.utility/html/utility
/utility224.htm
Example 1
Starts an Adaptive Server named SYBASE from the runserver file named RUN_servername in the
current directory:

startserver

Example 2
Starts an Adaptive Server named MYSERVER and a Backup Server named SYB_BACKUP:

startserver -f RUN_MYSERVER -f RUN_SYB_BACKUP

Example 3
Starts only the Backup Server SYB_BACKUP:

startserver -f RUN_SYB_BACKUP

1 of 6 9/30/2010 7:24 PM
Document Viewer http://rkm.bmc.com/rkm/viewdoc.jsp?remedy=1&doc=KM-0000000115...

To log in to Sybase (make sure that you source the Sybase profile first. See *** above regarding
setting environment variables. isql should be in your path if you sourced the SYBASE profile file):

isql -Uusername -Sservername -Ppassword

For example:

isql -Usa -Scruiser -P""

or

isql -UARAdmin -Scruiser12_5 -PAR#Admin#

IMPORTANT: FOR ARS INSTALLS YOU NEED TO SET THE DSQUERY ENVIRONMENT VARIABLE TO THE
SYBASE SERVER NAME. THIS VALUE IS NOT SET IN THE SYBASE.sh or the SYBASE.csh file.

***NOTE**** to execute sql statements from Sybase you need to hit enter and then type go. For
example:

1> select dbVersion from control


2> go
dbVersion
-----------
18

(1 row affected)
1>

*****NOTE**** Also, Sybase is case sensitive. For ARS data dictionary columns, you HAVE to use
proper case. ARS data dictionary standard is to capitalize the first letter in the second word like:
tfServer, filterId, schemaId and dbVersion

To see the version of DB you are using:

select @@version

To see a list of devices:

sp_helpdevice

To see information regarding a specific device:

sp_helpdevice device_name

This is how you create a device in Sybase (create one device for the DB, and one for the log):

1> disk init


2> name="ars5",
3> physname="/d2/sybase/databases/ars5.dat",
4> size=51200,
5> vdevno=6
6> go

The commas and quotes are required.

2 of 6 9/30/2010 7:24 PM
Document Viewer http://rkm.bmc.com/rkm/viewdoc.jsp?remedy=1&doc=KM-0000000115...

IMPORTANT:
(use sp_helpdevice to confirm unique name and datafile location)

name - whatever name you want to give to the device - this is what you will provide to the install
script.
physname - the fully qualified path the file to contain the information, make sure this is unique
size - in 2k blocks (512 times the number of megabytes that you want to use to create the device - in
the above example, the device will be 100Mb.)
vdevno - virtual device number - legal numbers are unused numbers between 1 and 255). If you want
to use a number higher than 10 you may need to use sp_configure to modify the default value for
"number of devices" to increase this.

To see a list of databases:

sp_helpdb

To get specifics regarding a specific database:

sp_helpdb [database_name]

To change databases:

use [database_name]

To see the columns and indexes for a table:

sp_help [tablename]

To see an alphabetically sorted list of all user tables in the database :

select name from sysobjects where type='U' order by 1

To see an alphabetically sorted list of all user views in the database :

select name from sysobjects where type='V' order by 1

To see the indexes the database:

select name from sysindexes

To see who's logged in:


sp_who

To determine a user's default database:

select name, dbname from master.dbo.syslogins

To see a list of user accounts:

select name from syslogins

To see a list of Sybase configuration parameters:

3 of 6 9/30/2010 7:24 PM
Document Viewer http://rkm.bmc.com/rkm/viewdoc.jsp?remedy=1&doc=KM-0000000115...

sp_configure

To change a configuration paramater (this varies depending on parameter):

sp_configure paramater_name, new_config

To change a database specific parameter use:

sp_dboption

To rename a database use

sp_renamedb oldname, newname (see KB 6487 for more explicit instructions)

To rename a table:

sp_rename oldtablename, newtablename

To change a database owner, run this command inside the database:

sp_changedbowner ownername

To view the text assoicated with a stored procedure:

sp_helptext procedure_name

To create a database on two already existing devices (this example would create a 150Mb db- 100 for
data, 50 for logs on devices device1 and device2 respectively):

create database dbname on device1=100


log on device2=50

to make a database larger (below example increases database 50Mb on device3):

alter database dbname on device3=50

To change a user's password:

sp_password caller_passwd, new_passwd, login_name

To drop a login:

sp_droplogin loginName
To back up a database (make sure the backup server is running: ps -aef | grep back)

dump database dbname to "fullyqualifiedpathtodumpfile"

For example:

dump database ARSystem to "/opt/remedy/ARSystem.dump"

load database dbname from "fullyqualifiedpathtodumpfile"

For example:

load database ARSystem from "/opt/remedy/ARSystem.dump"

To shutdown the database:

4 of 6 9/30/2010 7:24 PM
Document Viewer http://rkm.bmc.com/rkm/viewdoc.jsp?remedy=1&doc=KM-0000000115...

shutdown with nowait

for single user mode or possible database corruption, see kb 5703

To shutdown the backup server:


http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.dc38421_1500/html/ntconfig
/ntconfig28.htm

1. Use isql to log in to a server with System Administrator privileges:

isql -Usa -Ppassword -Sserver_name

2. Enter the following command to shut down the specified Backup Server:

1> shutdown SYB_BACKUP


2> go

After you shut down a Backup Server, you must wait at least 30 seconds before restarting it.

To confirm pagesize of database:


1) review output during startup of the database generated to console and captured to database
logging output file
Logical pagesize is xxxx bytes
2) log into isql prompt for the database in question and run the following query, replacing <table
name> with any table name in the database

select pagesize("<table name>")


Example verifying 16K pagesize:
1> select pagesize("control")
3> go

-----------
16384
(1 row affected)

Redirecting the output to a file:

Use this option only when you know exactly what you want to type. Extraneous characters, such as
backspace, will not be stored.

1.
Invoke isql with the -o option:

isql -Uusername -Ppassword -ofile_name

Although you do not see your isql entries, or the server's response, the isql session is stored in
the file file_name.

5 of 6 9/30/2010 7:24 PM
Document Viewer http://rkm.bmc.com/rkm/viewdoc.jsp?remedy=1&doc=KM-0000000115...

Categories
Administration/Database
Visibility Groups

Attachments

Filename Size
No records
Show Global Attachments

Feedback
How effective was this at resolving your problem?
1 2 3 4 5
Not Effective Very Effective

Optional: Additional feedback.

6 of 6 9/30/2010 7:24 PM