Sybase Isql Commands
Sybase Isql Commands
Sybase Isql Commands
comment /* .comment. */
Line continuation character '\'
isql
cd $SYBASE/$SYBASE_ASE/scripts
isql -Usa -PSecr3t -SSYBASE -iinstallpubs2 -e -oerrors.out
isql -S SYBASERAYS_SERVER_1 -U my_user -P my_pass -i /opt/sybase/ASE-
15_0/scripts/installdbccdb
use pubs2
go
exec sp_changedbowner sybtest
go
sp_changedbowner loginame [, true ]
sp_changedbowner my_user_1
startserver:
which SYBASE.sh
. SYBASE.sh
echo $SYBABE
cd $SYBASE/SYBASE_ASE/install
startserver -f RUN_servername
startserver -f RUN_SYB_BACKUP
shutdown :
isql -Usa -PSecr3t -SSYBASE
1> shutdown
2> go
top prev next
sp_help
sp_version
sp_help
go
sp_helpdb
go
sp_helpdb db1
go
sp_spaceused
select name, type, crdate from sysobjects;
sp_helpserver [server name];
select * sysservers;
sp_who
kill
tempdb_id ( [ spid ] )
Returns the database ID of the specified session's temporary database;
without spid,for the current session.
sp_configure
sp_configure 'disable disk mirroring', 0
go
sp_configure for all parameters
sp_configure 'nondefault' for non-default parameters
select id, csid, name, description from master..syscharsets where type >=
2000;
Interface File
# Interface File
$SYBASE/interfaces unix
%SYBASE%\INI\SQL.INI windows
backup db:
dump database pubs2 to "/mnt/backup/pubs2.bkp"
go
dump database db1 to "/dev/SYBASERAYS_SERVER_1/dumpfiles/dump1"
go
-- or simply truncate it
1> dump transaction pubs2 with truncate_only
2> go
-- restore a user db
load database
load transaction
online database
sp_displaylogin [ 'login_name' ]
sp_password
alter login.with passwd
sp_addlogin loginame, passwd [, defdb] [, deflanguage [, fullname]]]
sp_addlogin user1, password, @defdb = db1
go
sp_addlogin vyasab, Sunday01, NULL, NULL, "Abhisek Vyas"
go
sp_addlogin user2, password, db1, NULL, "user2"
go
exec sp_addlogin "sybtest", "SomePass"
go
sp_addlogin 'silveruser','silver','silvermaster'
go
sp_displaylogin [ 'login_name' ]
sp_modifylogin login_name, attribute, 'value'
use silvermaster
go
sp_role 'grant','sa_role','silveruser'
go
sp_changedbowner silveruser
go
/* create a developer profile */
sp_addlogin 'jsmith','yankees','silvermaster'
go
use silvermaster
go
sp_addalias 'jsmith','dbo'
go
/* change jsmith password, note how SA/SSO pwd is required here */
sp_password 'sa_pwd','dodgers','jsmith'
go
# -------------------------
Every user is a member of the group "public"
and can also be a member of one other group
Users remain in "public" even when they belong to another group
sp_addgroup grpname
sp_addgroup group1
go
# ------------------------
grant role role_granted [{, role_granted}...]to grantee [{, grantee}...]
# ------------------------
select u.name,v.name
from sysprotects p, master.dbo.spt_values v, sysusers u
where p.uid=u.uid
and p.action=v.number
and p.protecttype=1
and v.type = 'T'
and u.name!= 'dbo'
go
/* leave table where it is, but future allocations go to the new segment */
sp_placeobject new_seg , 'employee'
go
index:
# pre v15
select rowcnt( doampg ) from sysindexes where indid < 2 and id =
object_id( 'my_table' );
# after v15
select row_count( doampg ) from sysindexes where indid < 2 and id = object_id(
'my_table' );
extract ddl
-- find source code for stored procedure, function,views, triggers
sp_showtext
sp_helptext
defncopy utility
ddlgen utility
Data Type
-- ---------------
data type storage range/length comments
----------------- -------- ------------------- ----------------------------
integer 4 +/- 2.1 billion
smallint 2 +/- 32768
tinyint 1 0 .. 255
float 4 storage req is machine dependant
real 4
double precision 8
smallmoney 4 +/- 214,748 4 decimal places
money 8 +/- 922 trillion 4 decimal places
decimal/numeric varies
decimal(9,0) 4
decimal(12,0) 5
binary(n) length n
varbinary(n) length n
Only numeric data types with a precision of zero can be used for an identity
column.
-- ---------------------------------
distributed system
create proxy_table invoice_items at 'SERVERXXX01.dbxxx001.dbo.invoice_items'
go
sp_helpdevice
select * from master..sysdevices;
disk init
name = "db1_dbccdb_data",physname =
"/opt/sybase/data/db1_dbccdb_data.dat",size = "18M"
go
disk init
name = "db1_dbccdb_log",physname = "/opt/sybase/data/db1_dbccdb_log.dat", size
= "2M"
go
disk mirror
name = "log1", mirror = "/opt/sybase/data/log1_mirror.dat"
go
use master
go
sp_plan_dbccdb db1
go
T-SQL
set option isql_print_result_set=ALL
go
set option isql_show_multiple_result_sets=On
go
set flushmessage on
go
set nocount on
go
# quit a script
select syb_quit()
set quoted_identifier on
set rowcount 10
go
select emp_name, salary from employee order by salary desc
go
set rowcount 0
go
dbcc
dbcc checkstorage
Performance Monitoring
# monitoring
sp_monitorconfig
MDA tables
sp_sysmon
Excution Plan
# sql execution plan
set showplan
set statistics plancost
sp_showplan
show_plan()
sybase iq
sybase iq
sybase datawarehouse
sybase iq online docs
sypron whatis
IQ15 white Paper
sybase license
sysam status
sysam status -a
sysadm reread
set SYBASE_LICENSE_FILE=29722@bos;29733@nyc;@sfo
lmutil lmborrow -status
/bin/lmutil lmdiag .c ./licenses/SybaseIQ.lic
sybase ase
http://www.sypron.nl/whatis_ase.html
notes
sybase iq:
http://wenku.baidu.com/search?word=Sybase&lm=0&od=0&fr=top_home
http://wenku.baidu.com/view/6583c3ea856a561252d36fa2.html?re=view
http://wenku.baidu.com/view/8931ae68a98271fe910ef939.html
http://wenku.baidu.com/view/58dd9e795acfa1c7aa00cc9f.html
master
model
tempdb
sybsystemprocs
sp_help
sp_configure
sp_helpdevice
-- ----------------------
$SYBASE/interfaces
$SYBASE/SYBASE.cfg
-- ----------------------
-- check server status
showserver
-- ----------------------
startserver -f RUN_SYBASE
startserver -f RUN_SYB_BACKUP
-- ---------------------
isql -Usa -P
shutdown SYB_BACKUP
go
shutdown
go
-- --------------------
$SYBASE/install/.log
-- --------------------
isql
sp_configure "allow updates", 1
go
begin tran
go
use master
go
sp_helpdb
go
sp_helpdb MBFEWKDB
go
sp_helpdevice
go
sp_helpdevice device_name
go
sp_dropdevice device_name
sp_droplogin login_name
eg: sp_droplogin 'test'
sp_password old_passwd,new_passwd[,login_name]
sp_adduser login_name[,name_in_db[,grpname]]
# use sp_adduser to add a user to a specific database.
# The user must already have an Adaptive Server login.
syntax: sp_adduser loginame [, name_in_db [, grpname]]
use db1
go
sp_adduser myuser1
go
sp_adduser user2, user2_db, group1
go
use MBFEWKDB
go
sp_helpuser
go
misc
http://www.sybaseteam.com/sybase-dba-interview-questions-answers-guide-topic-
wise-t-882.html
http://www.geekinterview.com/Interview-Questions/Database/Sybase
SQL Anywhere
http://cnsk.gov.ab.ca/SQLHelp/dbeng50.htm setting up SQL Remote using Sybase
Central
http://cnsk.gov.ab.ca/SQLHelp/00000193.htm
http://sauron.wlu.ca/physcomp/ikotsireas/SybaseASAtutorial.pdf
http://sybaseblog.com/
http://sfdoccentral.symantec.com/sf/4.0/solaris/pdf/sf_syb_dbag.pdf
http://andrewmeph.wordpress.com/
http://andrewmeph.wordpress.com/
http://www.sypron.nl/main.html
edbarlow.com sybase software tools>
peppler
Sybase Tools
isql
sybase central
toad
rocket99
http://www.rocket99.com/cgi-bin/tech/search.pl http://www.rocket99.com/cgi-
bin/tech/search.pl?search=sybase
Sybase Administration A backup routine
Sybase : Administration : A backup routine
Sybase Administration Sybase ASE: Installing a new server via srvbuildres utility
Sybase : Administration : Sybase ASE: Installing a new server via srvbuildres utility
Sybase Administration Sybase ASE: Setting up the transaction log cache using
logiosize
Sybase : Administration : Sybase ASE: Setting up the transaction log cache using
logiosize
Sybase Administration Sybase IQ: Working with options and server settings
Sybase : Administration : Sybase IQ: Working with options and server settings
Sybase Transact-SQL Safely delete a large number of rows without blowing the t-log
Sybase : Transact-SQL : Safely delete a large number of rows without blowing the t-
log