unpack sybase
bzip2 -dc balabala.cpio.bz2 | cpio -dc
#prev line may be fine for rh but caused troubles for my debian (potato)
#i used this for potato
bunzip2 blabla.bz2
cpio -div -I blabla

#rh 
now
useradd -s /bin/false -d /usr/local/sybase/ sybase
groupadd -g 103 sybase
vipw
simply user and group for sybase with home where the sybase is placed
#again debian way of doing this
adduser --system --home /usr/local/sybase --group sybase

unpack both the client libraries and the server maybe we don't need 
the client libs (but maybe one day)

1. chown -R sybase:sybase /usr/local/sybase
pre 2. login as sybase
2. cd install
   ./set_permall
3. rm .sybinit and relogin
 start sybinit ? yes

--- sybinit section ---
pretty much follow the howto
configure master then backup
then libraries
--- end of sybinit ---

nja connecting to it
login as sybase user
isql -S -Usa -P

interesting note i named my main server PARENICA and BACKUP PAR_BACKUP
yet the name for backup is SYB_BACKUP though the network name is PAR_BACKUP

Ha toho bude vela

vytvorit db
create database 

pridat uzivatela
sp_addlogin jakub, heslo1, defaultnadb

zmena hesla
sp_password oldpass, newpass

sp_password null, newpass		- if pass was null

uzivatela treba este pridat do db
sp_addlogin jakub, heslo, 

priklad
sp_addlogin jakub, heslo, jakub,
@fullname="Jakub Labath"


uzivatela urobime vlastnikom databazi
use dbname
sp_changedbowner 

--------------
ZOBRAZENIA
sp_who - co sa deje v db (kto)
sp_helpuser - uzivatelia v danej db
sp_displaylogin - who am i - moze mat aj param potom to je nieco ako finger username

v ktorej db sme
select db_name()

zobrazit tabulky
sp_tables
sp_tables @table_type = "'TABLE', 'VIEW'"

stlpce
sp_columns foolist

---------------


vypnutie servrov
shutdown SYB_BACKUP
shutdown

pridanie noveho disku
tak tu dame prikaz disk init (veomo dobra vec)
1> disk init
2>   name = "dbdisk1",
3>   physname = "/var/lib/sybase/dbdisk1",
4>   vdevno = 3,
5>   size = 524288
6> go
kde size je v 2k blokoch a vdevno je cislo zariadenia
co zistime najlepsie
sp_helpdevice - pole device_number

no teraz chceme aby uzivatelske db isli na tento disk a nechali
ostatne disky na pokoji - pozri (6-6 sysadmin guide pre sybase)
kedze teraz je default master (to nechceme) tak najpr pridame dbdisk1 a
vyhodime mastera
sp_diskdefault dbdisk1, defaulton
sp_diskdefault master, defaultoff

fajn no a teraz je dbdisk1 nas datadisk a vzdy ked dakto urobi
create database tak to pojde nanho


tak disk by bol teraz chceme prestahovat db co sa omylom dostala
na mastera
hm predbezne nevedno (mohli by sme ju dumpnut a potom presknut inde)
ale zatial to nechame tak lebo vieme jej pridat velkost tak aby miesto
islo z ineho disku

cize ideme databaze vlastna pridat 600MB
alter database vlastna on default = 600
(inac trvalo to daku chvilku)

problemy ze zostala velka transakcia visiet
zaplneny transaction log ked ho chceme vuprazdnit urobime
dump tran vlastna with no_log

teraz skusime nastavit aby query padla ked sa log zaplni
sp_dboption vlastna, abort, true
use vlastna
checkpoint

tato option nezvladla chovanie ked sa uzivatel dalej snazil insertovat a
zase to cele islo do alarm sleep boha jeho

skusime to prepisovanie logu
sp_dboption vlastna, trunc, true
use vlastna
checkpoint


TABLUKY INDEXY SQL
--------------
Creating a primary index on table foolist (i used identity field)
create unique clustered index foolist_pk on foolist (id)
clustered = znamena ze riadky su v poradi indexu (moze byt len jeden na db)

Transactions

begin transaction 
commit transaction
rollback transaction

savepoints
save tran my_savepoint
rollback tran my_savepoint

select @@transtate - can be used to check if there where any errors
during previous statement

it is possible to have nested transactions
number off transactions -> select @@trancount

chained 1 unchained 0
select @@tranchained
in unchained 
usual sql behaviour - default
in chained all commands are in transaction and caling roolback
rollbacks entire session

isolation locks
0
select * from foolist
at isolation read uncommitted

1
select * from foolist
at isolation read committed

3
select * from foolist
at isolation serializable

default is 1
zda sa ze ked raz zacneme transakciu a zmenime data v tabulke
tak to znamena pri leveli 1 uz ich nikto iny neprecita
dokial neukoncime transakciu

oficialne serializable by malo zabezpecit ze sa v transakcii
neobjavia ziadne zmenene commitnute data z inej transakcie 
toto je zachovane v sybase aj s read commited :) kedze nikto uz necita
(nieto este meni) ako nahle my nieco pridame