You are on page 1of 107

1. ......................................................................................

9
1.1 ASE (Adaptive Server Enterprise) ...................................................................9
(1) ASE ............................................................................................................... 9
(2) ASE (DBA) ...................................................................................................... 9
(3) Database System Table .......................................................................................... 10
(4) Master database System table ......................................................................... 10
(5) Stored Procedure ................................................................................................... 12

1.2 ASE .................................................................... 12


(1) isql......................................................................................................................... 12
(2) Sybase Central ....................................................................................................... 16
(3) SQL Advantage ...................................................................................................... 16

1.3 ASE ........................................................................................... 17


(1) ASE ................................................................................................ 17
(2) ASE ............................................................................................... 18
(3) ASE ............................................................................... 18
(4) ASE .................................................................. 19

1.4 ASE (Configuration) .............................................................. 19


(1) Configuration Option ...................................................................................... 19
(2) Configuration ...................................................................................... 19
(3) Configuration ................................................................................................. 20

ASE Administration Guide - 1

(4) .......................................................................................................... 22

2. ............................................................................................. 25
2.1 Device ..............................................................................................25
(1) Disk Init.................................................................................................................. 25
(2) Default Device ....................................................................................................... 27
(3) Device ............................................................................................................ 27
(4) Device ............................................................................................................ 28

2.2 Mirroring ...................................................................................................28


(1) Mirroring .................................................................................................. 29
(2) Mirroring ................................................................................................. 29
(3) Mirroring ........................................................................................................ 30

3. (DATABASE) .............................................................. 31
3.1 Create Database ......................................................................................... 31
(1) Syntax.................................................................................................................... 31
(2) (Data) (Log) Device ................................................................... 32
(3) (Ownership) ...................................................................... 32
(4) Database Create (Permission) ................................................................... 33
(5) Database Option ........................................................................... 33
(6) Log Device ....................................................................... 34

3.2 Database ............................................................................................35


(1) Data Size .................................................................................................. 35
(2) Log Size ................................................................................................... 35

ASE Administration Guide - 2

(3) Database ........................................................................................................ 35


(4) Tempdb Size .......................................................................................................... 36

3.3 Using Segments ........................................................................................36


(1) Segments ............................................................................................... 36
(2) User define Segments .......................................................................................... 36
(3) Segments ...................................................................................................... 36
(4) Segments ..................................................................................................... 36
(5) Segments ..................................................................................................... 37
(6) Segments ..................................................................................................... 37
(7) sp_extentsegment ............................................................................................... 37

3.4 Data Partitioning ........................................................................................38


(1) Partitioning ..................................................................................................... 38
(2) Partitioning .................................................................................................... 41

4. ACCESS (CONTROLLING) .............................................................. 43


4.1 User .................................................................................................43
(1) Database Owner(dbo) ................................................................................. 43
(2) sa Login ................................................................................................................. 43
(3) Role....................................................................................................................... 43

4.2 System Security ..........................................................................................44


(1) Login ..................................................................................................................... 44
(2) User ...................................................................................................................... 44

ASE Administration Guide - 3

(3) Guest, Alias .......................................................................................................... 45


(4) Group ................................................................................................................... 45
(5) Role....................................................................................................................... 46
(6) Command Permission ............................................................................................ 47
(7) Object Permission .................................................................................................. 47
(8) ASE Controlling Functions ............................................................ 48
(9) Object or user Permission ....................................................... 48

5. AUDITING ........................................................................................... 49
5.1 Auditing ..............................................................................................49
(1) Audit .............................................................................................................. 49
(2) Audit system install and management .................................................................... 49
(3) Audit system Query ............................................................................................... 50

6. BUFFER MANAGER ............................................................................. 52


6.1 Default Cache.............................................................................................52
6.2 Named Cache ............................................................................................52
(1) Named Cache ........................................................................................... 53
(2) Named Cache .......................................................................................... 53
(3) Cache Object Binding, Unbinding ....................................................... 53
(4) Named Cache Delete ...................................................................................... 55

6.3 Buffer Pool Sizing (Large I/O)......................................................................55

ASE Administration Guide - 4

(1) Buffer Pool .............................................................................................. 56


(2) Buffer Pool .............................................................................................. 56
(3) Buffer Pool Delete .......................................................................................... 57

7. CACHE STRATEGY OPTIMIZATION....................................................... 58


7.1 Prefetch Strategy (Large I/O) ......................................................................58
(1) Object-Level Prefetch Setting ........................................................................... 58
(2) Session-Level Prefetch Setting .......................................................................... 59
(3) Query-Level Prefetch Setting ............................................................................ 59

7.2 Fetch-and-Discard (MRU) Strategy ..............................................................59


(1) Object-Level Fetch-and-Discard Setting ............................................................ 60

7.3 Joincount ..................................................................................................60

8. PARALLEL PROCESSING ...................................................................... 61


8.1 Parallel Access ............................................................................................ 61
(1) Parallel access ................................................................................ 61
(2) Access Methods..................................................................................................... 61
(3) Parallel Scan ................................................................................................... 62
(4) Parallel access SQL Statements ......................................................... 65

8.2 Parallel scan configuration ..........................................................................65


(1) Server-wide Parameters.......................................................................................... 65
(2) Session Parameters ................................................................................................ 66
(3) Statement level ...................................................................................................... 66

ASE Administration Guide - 5

9. TRANSACTION ............................................................................. 68
9.1 Transaction .........................................................................................68
(1) Transaction Logging ....................................................................... 68
(2) Checkpoint ............................................................................................................ 68
(3) Write-Ahead Log ................................................................................................... 68

9.2 Recovery .............................................................................................70


(1) Recovery .......................................................................... 70
(2) Recovery Option .................................................................................................... 70

9.3 User Log Cache (ULC)................................................................................72


(1) user log cache..................................................................................................... 72
(2) User Log Cache Flush? ........................................................................ 72

10. BACKUP ............................................................................................ 73


10.1 Backup Server ...........................................................................................73
(1) Backup Server . ..................................................................................... 73
(2) Backup / Restore ........................................................................................... 73
(3) Backup / Restore Flow () .......................................................................... 74
(4) Recovery ............................................................................................................... 74
(5) Local Backup Server ............................................................................................... 76
(6) Remote Backup Server ........................................................................................... 76
(7) Dump Device ............................................................................................ 77

10.2 Dump ......................................................................................................77


(1) Dump Database. ................................................................................................... 77
(2) Dump Transaction. ............................................................................................... 79

ASE Administration Guide - 6

10.3 Load ........................................................................................................80


(1) Load Database ...................................................................................................... 80
(2) Load Transaction. ................................................................................................. 80

10.4 Point-in-time Recovery .............................................................................82


(1) Point-in-time Recovery ? ..................................................................................... 82
(2) . ..................................................................................................................... 82
(3) Point-in-time Recovery . ................................................................. 82
(4) Point-in-time Recovery ....................................................................................... 82

10.5 Backup Miscellaneous........................................................................84


(1) Backup ........................................................................................................... 84
(2) Transaction Log release . ....................................... 84

11. MONITORING & TROUBLESHOOTING SQL SERVER ............................. 86


11.1 Montoring ...............................................................................................86
(1) Monitoring . .................................................................................................... 86
(2) Threshold Manager................................................................................................ 88
(3) Database Integrity.................................................................................................. 89
(4) Resource Governor ................................................................................................ 91

11.2 Troubleshooting ......................................................................................92


(1) Server Start ........................................................................................... 92
(2) Server Start Access .................................................................. 93
(3) Database ................................................................................. 94
(4) User Object ............................................................................ 95
(5) Process Down Hang. .................................................................................... 97

ASE Administration Guide - 7

12. ADMINISTRATION TOPIC ..................................................... 98


12.1 Data Management tools. ..........................................................................98
(1) Defncopy ............................................................................................................... 98
(2) Bulk Copy .............................................................................................................. 98

12.2 Remote Access ...................................................................................... 101


(1) Server ............................................................................................................ 101
(2) Remote Login Mapping .................................................................................... 102

12.3 Component Integration Services (CIS) .................................................... 104


(1) .................................................................................................................... 104
(2) ..................................................................................................................... 104

12.4 Logical Process Manager ........................................................................ 105

13. 12.5 ........................................................................... 78


13.1 12.5.0.1. ...................................................................................................78
13.2 12.5.1.......................................................................................................78
13.3 12.5.2. .....................................................................................................78
13.4 12.5.3 ......................................................................................................79

ASE Administration Guide - 8

1.
1.1 ASE (Adaptive Server Enterprise)

(1) ASE

Multi-threaded Single Process


CPU Thread Task .
CPU .

Integrity security

Department of Defense Trusted Computer System Evaluation Criteria"(TCSEC)
B1

High Availability
Cluster SMP .
,
.

Cost-based Optimizer.
Optimizer Query Plan
. , optimize query .

(2) ASE (DBA)

ASE Administration Guide - 9

ASE , .
, , .
ASE Login account .
ASE .
.
ASE .
ASE (Auditing) .

(3) Database System Table


ASE table .

System table
- sysobjects

- syslogs

- sysprotects

- sysprocedures

- sysusers

- syssegments

- sysroles

- sysalternates

- systypes

- syscolumns

- sysindexes

- sysdepends

- syskeys

- sysgams

- systhreshold

- sysreferences

- sysattributes

- syspartitions

, System Table
.

(4) Master database System table


Master database System table Server
System table .

ASE Administration Guide - 10

System table
- sysservers

- syslogins

- sysdevices

- sysdatabases

- syslanguages

- syscharsets

- sysprocesses

- syscurconfigs

- syssrvroles

- sysmessages

- sysconfigures

- syslocks

- syssecmechs

- sysmonitors

- sysengines

- sysremotelogins

- syslisteners

- syslogsholds

- systimeranges

- sysresourcelimits

, Master database
System table .

Recovery Master database Master


database .

ASE Administration Guide - 11

(5) Stored Procedure


SYBASE Stored Procedure T-SQL control-of-flow language .
Stored Procedure User Defined Stored Procedure System Stored Procedure
, User

defined Stored Procedure stored Procedure Performance


Function Server Application ,
System StoredProcedures System Administrative Task Server
Procedure sp_ Stored Procedure
System Table System Stored Procedure sybsystemproc
DB $SYBASE/scripts dir installmaster .

sp_helpdb : database

sp_addumpdevice : backup

sp_addlogin (syslogins)

sp_who (sysprocesses)

1.2 ASE
(1) isql

ASE .

ASE Transact-SQL .

.
: $ isql -U username -P password [-S servername ]

1> <some SQL statements>

ASE Administration Guide - 12

2> go
S DSQUERY ASE .
Isql SQL
Reset :
vi

: isql vi .

quit

: isql .

:r file_name :file isql .

ASE Administration Guide - 13


Database, Object, User, Permission , OS
.

/* template.sql */
/* set the current database */
use pubs2
go
/* stores procedure , drop */
if exists(select 1 from sysobjects where type = P and
name = stored_proc_name)
begin
drop proc stored_proc_name
end
go
/* stored procdure create */
create proc stored_proc_name
(
.
.
return
go
/* stored procdure permission assign */
grant execute on stored_proc_name to public
go

Batch go
.
comment /* ... */ -- .

ASE Administration Guide - 14

Stored Procedure execute .


: $ isql -U user_name -P passwd -i filename $ isql -U
user_name -P passwd < filename

** Utility Programs for UNIX Platforms .

ASE Administration Guide - 15

(2) Sybase Central

ASE, Replication Server, Adaptive Server Anywhere, ASIQ, NetImpact Dynamo


.

Connect, disconnect, server starting, server stopping, ASE troubleshooting

Sybase central connecting / disconnecting


Tool menu -> connect -> logon dialog box
User id
Password
Server name dropdown list ASE
OK
Disconnect disconnect ASE
File menu disconnect

Sybase central ASE


ASE
ASE ASE (start) Yes

ASE
ASE (stop)
ASE .

(3) SQL Advantage


isql Transact-SQL(T-SQL)

ASE Administration Guide - 16

File Open
File menu Open
Open Drive, Directory
List box File

File Load
File menu Load
Load Drive, Directory
File Loading

1.3 ASE

(1) ASE

Sybase Install startserver.

$SYBASE/install RUN_xxx .

RUN_xxx RUN_sqlservername.
, ASE Server ACCOUNT RUN_ACCOUNT .
) cd $SYBASE/install
startserver -f RUN_SYBASE [-m]
* -f : RUNSERVER file
-m : single-user mode /* troubleshooting */

showserver server
) $ showserver
$ ps -ef|grep dataserver

ASE Administration Guide - 17

(2) ASE

isql sa login shutdown .

Syntax : shutdown [backup_server] [with nowait]


)
1>shutdown SYB_BACKUP /*BACKUP */
2>go
1>shutdown [with nowait]
2>go
* with nowait
(troubleshooting) .
* BACKUP ASE

(3) ASE

UNIX /etc/rc File .


)
SYBASE = /home/u/test/sybase
export SYBASE
su sybase -c $SYBASE/install/startserver -f $SYBASE/install/RUN_TEST &

SYBASE=/home/u/test/sybase \
su sybase -c $SYBASE/install/startserver -f $SYBASE/install/RUN_TEST &

* /home/u/test : SYBASE
* ASE server TEST
* UNIX OS Unix manual

ASE Administration Guide - 18

(4) ASE

showserver ps -ef | grep dataserver

$SYBASE/install/errorlog

ASE login

ASE (env )

1.4 ASE (Configuration)


ASE Performance .

(1) Configuration Option

Backup/recovery

Cache manager

Disk I/O

Network

O/S resources

Memory

Processors

User environment

Lock manager

(2) Configuration

Syntax :

1. sp_configure : config .
2. sp_configure [group name] : group .

ASE Administration Guide - 19

3. sp_configure [optname [, optvalue]] : config


.

reconfigure with override: ( Ver 10.x


)

1> sp_configure remote access


2> go
name

min

max

config_value run_value

----------------------------------------------------------------remote access

Dynamic Option : ASE .

Static Option

: ASE .

1>sp_configure remote access,0


2>go
* ASE /*startserver */

(3) Configuration

Configuration ASE Configuration .


( (SQL Server 10) Master Device Config Block )

sp_configure Configuration .

ASE Configuration
($SYBASE/<servername>.cfg) .

ASE Administration Guide - 20

Configuration (OLTP,DSS).
Configuration .
Configuration .(11.0.x Version buildmaster r
)
11.0.x Version Reconfigure .

Command
sp_configure : .
Syntax : sp_configure configuration file [,0,< sub_command>,<fileName>]

* sub_command - read, verify, write, restore


sp_displaylevel : User Display Level .
Syntax : sp_displaylevel [login_name [,level]]

* level - basic, intermediate, comprehensive

ASE Administration Guide - 21

(4)

total memory
Hardware physical memory dataserver memory .
Syntax : sp_configure total memory,value
*) value 2K . 30M 15360 (2K
*15360=30720K).

Procedure cache
Stored Procedure trigger compile object cache
% ..
cache space(data cache + procedure cache) 20% default
(total memory procedure cache ) .
Procedure cache .
max(# of concurrent users) * (size of largest plan) * 1.25

/* */

max(# of concurrent users) * (avg. Plan size) * 1.25

/**/

:Sp_configure procedure cache, n(%)

max online engines


SMP H/W CPU .
CPU CPU - 1 setup.

size of auto identity


sp_dboption auto identity table Identity column precision .
*) default 10 precision 10 insert error .
Identity 10 .
.
Syntax : sp_configure size of auto identity, <value>
* <value> : 1 - 38

print deadlock information

ASE Administration Guide - 22

errorlog file deadlock .


.

max network packet size



.
512 Byte 512 Byte
image bcp .
additional network memory

additional network memory


max network packet size .
)

Application

Packet Size

Bcp

8192

Client-library

8192

Client-library

4096

Client-library

4096

Total

24576

Multiply bt 3 buffers/user

Overhead

*3
73728

Compute 2% overhead
Add overhead

*.02=1474
+ 1474

Additional network memory


Round up to multiply of 2048

75202
75776

lock promotion

ASE Administration Guide - 23

ASE Lock Page Lock Table Lock Lock


Table Page Locking Page
Lock .
(Lock promotion PCT /Lock promotion LWM /Lock promotion
HWM)
: sp_setpglockpromote server | database | table, obj_name,
new_lwm, new_hwm, new_pct
sp_dropglockpromote database | table , obj_name

ASE Administration Guide - 24

2.

2.1 Device

ASE .

disk init ASE Raw Unix


Logical Name Physical Name .

sysdevices
name

c
d

.... phyname

data_dev1 .....disk1d
data_dev1

logical name
physical name

(1) Disk Init


Syntax : disk init
name = device_name,
physname = physical_name,
vdevno = virtual_device_number,
size = number_of_pages
......
[, contiguous] /* OpenVMS only */

ASE Administration Guide - 25

* name : Logical name


physname : Sybase login id
.
vdevno : 1 ~ 255 ( max configured - 1)
size : 2k page ( 256 MB ).

ASE Administration Guide - 26

) raw device(/dev/rsd2d) 360MB


disk init
name = data_dev1,
physname = /dev/rsd2d,
vdevno = 2, /* sybase */
size = 92160 /* ( 256 * 360M ) */

sp_helpdevice : Device .

(2) Default Device

Device Default Device .

Device sp_diskdefault Default Device .


Syntax : sp_diskdefault logical name, {defaulton | defaultoff}
)

exec sp_diskdefault master, defaultoff


exec sp_diskdefault data_dev1, defaulton

ASE Master Device Default Device .

(3) Device

Device Device .
Syntax : sp_dropdevice device_name

Device Device Device number ASE


.

sp_dropdevice ASE Device ASE Unix


rm .

ASE Administration Guide - 27

(4) Device

Master Database select * from sysdevices

sp_helpdevice [Device name]

2.2 Mirroring

Database Device ASE .

Write.

Read Primary Side .

ASE Administration Guide - 28

unmirrored:
data_dev1

mirrored:

disk1

data_dev1
disk1

(1) Mirroring

Downtime .
.

S/W .
(Disk Storage) .
Write .

Device Mirroring .
Master Device
Log Devices
Active Device

(2) Mirroring

Syntax : disk mirror


name = device name,
mirror = physical_name
[ , writes = {serial | noserial}]

ASE Administration Guide - 29

disk2

) disk mirror
name = data_dev1,
mirror = /dev/rsd3d

Master Device Mirror RUNSERVER Mirror Physical Name


.
) dataserver -ddevicename .... [ -rmastermirror_devicename]

Mirroring
disk unmirror name = device_name

Mirroring
disk remirror name = device_name

Mirroring
disk unmirror name = device_name, mode = remove

Mirroring
disk unmirror name = device_name, side = primary, mode = retain

(3) Mirroring

sp_helpdevice Mirroring .

ASE Administration Guide - 30

3. (Database)

3.1 Create Database

model

master

new database

physical device

logical device

(1) Syntax
create database database_name
[on database_device [= size]
[, database_device = size]] ...]
[log on database_device = [size]] ...]
[with override]
[for load]

Device Default Device .

(Size) Configuration Default Database


Size .

(User) Model 2MB


.

ASE Administration Guide - 31

Master .
) create database pubs2
create database salesdb on data_dev1 = 5
create database salesdb on data_dev1 = 5
log on log_dev1 = 2
create database salesdb on data_dev1 = 5
log on data_dev1 = 2 with override

Device with override


.

(2) (Data) (Log) Device

.
DB .
Mirroring .

(3) (Ownership)

Database User Database Owner ,

System (sa Role)

Database . Ownership DB
.

Syntax : sp_changedbowner login_name

login_name Server , Database User .


)

1> use productdb


2> go

ASE Administration Guide - 32

1> sp_changedbowner fred


2> go

Database .
Syntax : sp_helpdb [database_name]

(4) Database Create (Permission)

Database .

grant create database to mary

(5) Database Option

Option
abort tran on log full : Last-chance threshold
.
allow nulls by default : NULL NULL
.
dbo use only

: dbo Database

ddl in tran

: DDL

Identity in nonunique index : Table Index Unique


Table Index Key identity
no chkpt on recovery : Recovery checkpoint record

no free space acctg

: non-log Free space Threshold


read only

: Database

ASE Administration Guide - 33

select into/bulkcopy/pllsort : writetext, select into Fast bulk , Parallel Sort

single user

: Database

trunc. log on chkpt

: Database Checkpoint
Truncate 5

unique auto_identity

: Table identity non-clustered Index

Syntax : sp_dboption [dbname, option_name, {true | false}

1>use master /* must be in master */


2>go
1>sp_dboption smalldb, read only, true
2>go
1>use smalldb
2>go
1>checkpoint /* must run in your database */
2>go

(6) Log Device


1) Log Dump.(dump tran ....... with truncate_log)
2) Database Device .(alter database)
3) sp_logdevice Log Device .
4) page(2K) dummy update .
5) Log Dump.(dump tran ....... with truncate_log)
6) Dbcc chaecktable(syslogs) .

ASE Administration Guide - 34

3.2 Database
Alter Database dbo sa Database .

expansion

expansion

OR

data_dev1

data_dev1

data_dev2

(1) Data Size

Syntax : alter database database_name


[on {default | database_device} [= size]]
[log on database_device [= size]]

alter database pubs2 /* default device */


alter database pubs2 on data_dev1 = 3 /* data_dev1 device */

(2) Log Size

) alter database pubs2 log on log_dev2 = 4

(3) Database

Syntax : drop database database_name

Database .

ASE Administration Guide - 35

(4) Tempdb Size

Query Statement Server tempdb .


- Order by ( Index )
- Group by
- Distinct
- create table( #name tempdb..name)

Query User tempdb Size .

3.3 Using Segments


(1) Segments

Database Device device table or index


.

database system, default, logsegment .

(2) User define Segments

sp_addsegment segname, dbname, device_name

(3) Segments

create table tableA(.....) on seg1

create table tableB(.....) on seg2

(4) Segments

sp_dropsegment
) sp_dropsegment default, salesdb, data_dev3

ASE Administration Guide - 36

(5) Segments

sp_helpsegment [segname]

(6) Segments

segment device

sp_placeobject seg2, tableA

(7) sp_extentsegment

segment database device .

sp_extendsegment segname, dbname, devname

ASE Administration Guide - 37

3.4 Data Partitioning


(1) Partitioning

Query
. ASE 11.5


11.X Release
Heap Insertion Point
I/O
11.5 Release
Query (,
Worker Process ).

bcp in
load balancing .

Multiple Insertion Point


Double-linked List . Clustered Index
Heap Table
Exclusive-Lock
. Heap Table
Lock contention .

Reduced I/O Contention


ASE Administration Guide - 38

I/O Contention
.
.
I/O .

Fragment . Query I/O
Contention , .

ASE Administration Guide - 39

I/O Balancing
Load Balancing .

Clustered index Split


Balance
.
default segment .
Fragment .
fragment .
Bcp batch
fragment . non-batch .

.
Pre-11.5 :

Table with clustered indexes

System tables

Work tables

Temporary tables

( .)

11.5 :

System tables

Work tables. work table


.

( .)

Text and Image Columns

ASE Administration Guide - 40

Text Image Text Image


.

(2) Partitioning

default segment ,

default segment .

default segment


1> sp_addsegment newsegment, my_database, data_dev1
2> go

3
1> sp_extendsegment newsegment, my_database, data_dev2
2> go
1> sp_extendsegment newsegment, my_database, data_dev3
2> go


1> create table my_table
2> (names, varchar(80) not null)
3> on newsegment
4> go


1> alter table my_table partition 3

ASE Administration Guide - 41

2> go

....

User1
Last Page

User2

Table

....
Last Page

....
Last Page

Partition .
Syntax : alter table table_name unpartition
ex) alter table publishers unpartition

Partition .
Syntax : sp_helpartition table_name

ASE Administration Guide - 42

4. Access (Controlling)

4.1 User
(1) Database Owner(dbo)

Database User .

Database Dump Load.

Checkpoint, dbcc .

Database Objects User .

(2) sa Login

ASE Install Password null.

Role (System administrator, system security officer, system operator)


SQL

Master Database Owner

Database Owner .

Database Objects Access .

(3) Role

SA role : Administrative Tasks

disk storage

logins drop, modify, lock, unlock

SA grant/revoke

User database create

ASE user permission

ASE Processes shutdown

ASE Administration Guide - 43

SSO role : Security Tasks

ASE login

Password

User define role ,

SSO, OPER role

Audit system

OPER role : Dumps & Loads

4.2 System Security


(1) Login

ASE Connect .

Master Database syslogins Table . (select * from syslogins)

Syntax : sp_addlogin loginname, passwd [, defaultdb [, deflanguage [,fullname]]]

) sp_addlogin claire, bleurouge, public_db, french, Claire Barr


sp_addlogin robby, playball, education

Password 6byte.
Default Database Master Database Default .

Command
sp_modifylogin login_name, option, values
sp_droplogin login_name
sp_addlogin login_name, password
sp_password caller_passwd,new_passwd [, login_name]
sp_configure password, n
sp_locklogin [login_name, {lock | unlock}]

(2) User

Database Access .

Database sysusers Table . (select * from sysusers)

ASE Administration Guide - 44

Syntax : sp_adduser login_name [, name_in_db [, grpname]]

User : sp_dropuser name_in_db

) sp_adduser claire, claireb


sp_adduser robby
dbo User Add .

syslogins
name
claire
robby

master

user3db
user2db
user1db

sysusers

sysusers

name

name

claireb
robby

fredp
maryj

(3) Guest, Alias

Guest : login guest Database Access .


Syntax : sp_adduser guest

Alias : Database User Login .


Ex) User dbo .
Syntax : sp_addalias loginame, name_in_db

Alias drop : Sp_dropalias loginname

(4) Group

Users Group Permission .

sp_addgroup engineering
,
sp_adduser robert, bob, engineering

ASE Administration Guide - 45

or
sp_changegroup engineering, bob

public Group .

group : sp_helpgroup [grpname]

(5) Role

SQL Server Install , sa login SA, SSO,OPER role .

sp_role User Role .


Syntax : sp_role {grant | revoke}, {sa_role | sso_role | oper_role}, login_name
) sp_role grant, sa_role, robby

Login Log in Login Role ,


.
Syntax : set role {sa_role | sso_role | oper_role} {on | off}
) set role sa_role off

Login Role .
select show_role()

procedure role check function


proc_role
) create proc test_proc
as
if (proc_role(sa_role) = 0)
begin
print You do not have the right role.
Return 1
end

else
print You have SA role.
Return 0

system role Enable or disable

ASE Administration Guide - 46

set role {sa_role | sso_role | oper_role} on


set role {sa_role | sso_role | oper_role} off

(6) Command Permission

Command Object create, alter, drop


.

Grant
Syntax :

grant {all [privileges] | command_list}


to {public | name_list | role_name}

grant create rule to fred


grant create rule, create table to engineering

Revoke
Syntax :

revoke {all [privileges] | command_list}


from {public | name_list | role_anme}

revoke create table from public


revoke create rule from fred

(7) Object Permission

Object Permission Object Access select, insert, delete, update,


references, execute .

grant permission : create index, create trigger, alter table, drop table, truncate
table, update statistics

Grant
Syntax : grant {all [privileges] | permission_list}
on {table_name [(column_list)]
view_name [(column_list)]
stored_procedure_name }

ASE Administration Guide - 47

to {public | name_list | role_name}


[ with grant option ]
) grant update on titles (price, advance) to public
grant execute on new_proc to sa_role
** With Grant Option : User Permission .

Revoke
Syntax :

revoke [grant option for] {all [privileges] | permission_list}


on {table_name [(column_list)]
view_name [(column_list)]
stored_procedure_name }
from {public | name_list | role_name} [cascade]

revoke insert, delete on titles from mary, sales


revoke update on titles (price, advance) from public

(8) ASE Controlling Functions


. suser_id( )

. db_id( )

. user_id( )

. db_name( )

. user_name( )

. proc_role( )

select suser_id( )
select suser_id(fred)

(9) Object or user Permission

. sp_helprotect object_name

. sp_helprotect user_name

ASE Administration Guide - 48

. suser_name( )

5. Auditing

5.1 Auditing
Security system (sybsecurity)

database object .

login monitoring

login .

(1) Audit

ASE Level

: logins, logouts, reboots, remote procedure calls, dbcc commands,


security, disk, adhoc

Database Level : grant, revoke, truncate, drop, load, create, alter, bcp, bind, unbind,
dbaccess, dump

Object Level

: delete, exec_procedure, exec_trigger, func_obj_access, insert,


reference, select, update

User Level

: cmdtext

(2) Audit system install and management

auditinit install

audit trail table

audit table data device

syslogs transaction log device

Install syslogs system table device

ASE Administration Guide - 49

sp_configure audit table


syntax) sp_configure current audit table, n [, with truncate]

auditing install default option active sp_dboption .

auditing install sp_audit auditing option set


syntax) sp_audit option, login_name, object_name [, setting]
option : audit action name( select, update, create..)
setting : OFF - action auditing Off
PASS - action , audit record
FAIL - action , audit record
ON , audit record

) sp_audit create,all,db1,both

auditing enable / disable


syntax) sp_configure auditing, [0 | 1]

(3) Audit system Query


)
1>use audit_db
2>go
1>select * from audit_data
2>where loginname = bob
3>and eventtime like Jul 5% 97
4>go

Contents of sysaudits

event

: type of event being audited

eventmod

: more information about the event being audited

spid, suid, dbid, objid : process IDs

eventtime

: data and time that the audited event occurred

ASE Administration Guide - 50

sequence

: sequence number of the record within a single event

xactid

: ID of the tranction containing the audited event

loginname

: login name corresponding to suid

dbname

: database name corresponding to dbid

objname

: object name corresponding to dbis

objowner

: name of the owner of objid

extrainfo

: additional information about the audited event

ASE Administration Guide - 51

6. Buffer Manager

Performance I/O .
Buffer manager (contention) .
DSS OLTP Memory .

6.1 Default Cache

SQL Server Boot Cache DSS OLTP Mixed


Cache.

Object Named Cache Default Cache .

Recovery, Load Database, Load Transaction .

Default Cache Delete Size .(Size : 512K)

Default Cache 2K Buffer Pool Size .

6.2 Named Cache

SMP Buffer Manager Contention .

Memory Memory .

ASE Administration Guide - 52

Named Cache
OLTP

Hash

2K

OPTIMIZER
DSS

16 K

OLTP DSS .

Memory Disk I/O .

Buffer pool sizing : 2K, 4K, 8K, 16K I/O

(1) Named Cache

Syntax : sp_cacheconfig [cache_name [,cache_size [P|K|M|G] [,logonly | mixed]]]

: Size 512K .
cache size memory .

) 1> sp_cacheconfig pub_cache, 10M


2> go
1> sp_helpcache
2> go

(2) Named Cache

1> sp_cacheconfig pub_cache, logonly


2> go

(3) Cache Object Binding, Unbinding

Syntax : sp_bindcache cache_name, dbname[, [owner.]table [, index] | text only]

ASE Administration Guide - 53

sp_unbindcache dbname[, [owner.]table [, index] | text only]


sp_unbindcache_all cache_name


Binding Entity Cache .
Database Binding Master Database .
Object Cursor Open, Dirty Read .
syslogs Binding cache Log-only Cache .

Ex) 1> sp_bindcache pub_cache, pubs2, authors


2> go

1> sp_bindcache pub_cache, pubs2, titles, titleind


2> go

1>sp_unbindcache pubs2, authors


2>go
1>sp_unbindcache_all pub_cache
2>go

ASE Administration Guide - 54

(4) Named Cache Delete

1> sp_cacheconfig pub_cache, 0


2> go

: Named cache delete object unbind

6.3 Buffer Pool Sizing (Large I/O)

SQL Server Data Page Disk Access Physical I/O


.

2K page 8 2K page 8 Throughput


.

DSS .

2K, 4K, 8K, 16K I/O .

ASE Administration Guide - 55

(1) Buffer Pool


Syntax

sp_poolconfig

cache_name,

pool_size

from_io_sizeK]

1> sp_poolconfig pub_cache, 4M, 4K


2> go

(2) Buffer Pool


)

1> sp_poolconfig pub_cache, 1M, 4K, 16K


2> go
1> sp_poolconfig pub_cache, 8K, wash=128K
2> go

ASE Administration Guide - 56

[P|K|M|G],

to_io_sizeK

[,

(3) Buffer Pool Delete


)

1> sp_poolconfig pub_cache, 0, 16K


2> go

ASE Administration Guide - 57

7. Cache Strategy Optimization

Optimizer Logical Physical I/O .

Optimizer Named Cache, Large I/Os, Query Table .

Buffer Manager Strategy .

7.1 Prefetch Strategy (Large I/O)

Physical I/O Disk I/O Physical page .

Default large I/O on .

(1) Object-Level Prefetch Setting

Syntax : sp_cachestrategy dbname [, [ownername.]tablename [,indexname | text only |


table only [, prefetch | mru, on | off]]]

1>sp_cachestrategy employee, prefetch, off


2>go

ASE Administration Guide - 58

(2) Session-Level Prefetch Setting

Syntax : set prefetch off | on

OLTP Performance Prefetch Disable .

(3) Query-Level Prefetch Setting

Syntax : select select_list from [ {tablename} [(indid | index indname [prefetch size]
[lru | mru] )] [holdlock | noholdlock] where ......

1> select * from authors (prefetch 4)


2>go

7.2 Fetch-and-Discard (MRU) Strategy

Cache Page MRU


Page .

Default MRU on .

S
DS

T
OL

MRU
Regular
Strategy

Wash
Marker

DS

LRU
MRU
Strategy

Data Pages
in Use

ASE Administration Guide - 59

(1) Object-Level Fetch-and-Discard Setting

Syntax : sp_cachestrategy objectname, [prefetch | mru [, off | on ]]

1> sp_cachestrategy authors, mru, on


2>go

7.3 Joincount

ASE 4 Table Join Optimizer .

ASE 5 -8 Table Join Optimizer .

Syntax : set tablecount <#>

1> set tablecount 6


2>go

ASE Administration Guide - 60

8. Parallel Processing
Adaptive Server 11.5 query parallel access
. parallel query

8.1 Parallel Access


(1) Parallel access

table partitioning

scan width

partition skew

selection of a useful index

available work process

existence of clustered index

(2) Access Methods

Process
1

Access

Process
2

Process
3

Process
4

- Thread
- Thread
Result Set(bucket)

Merge
- Bucket
Result set Merge

Merge mechanism

ASE Administration Guide - 61

- Merge Result Set Client

(3) Parallel Scan

Accessing Data Without an Index

Accessing Data Using a Non-Clustered Index

Accessing Data Using a Clustered Index

One User, One Process

Partition scans : partition tables


.
, I/O throughput

ASE Administration Guide - 62

Partition Clustered index scan


root page
I
n
d
e
x
Level 0

data
pages

Partition 1

Partition 2

Index pages accessed by threads 2,3


Index pages accessed by threads 1,2,3,4
Partition scanned by thread 4

Hash scans

Partition 3

Partition 4

Partition scanned by thread 3


Partition scanned by thread 2
Partition 1 terminates

: partition tables

worker process worker process

hash
.
ii . Clustered index hash scan .
iii . optimizer

ASE Administration Guide - 63

P-hash Clustered index scan


root page
I
n
d
e
x

Level 0

data
pages

Data pages accessed by thread 2


Data pages accessed by thread1

Index pages accessed by threads 1,2

Clustered index

Scan type

Unpartitioned tables

Partitioned tables

Table scan

Hash-based table scan

Partition-based table scan

Non-clusted index

Hash-based non-clust

Hash-based non-clust index scan

scan

index scan

Clustered index scan

none

Partition-based clustered index


scan

Clustered index table


Scan type

Unpartitioned tables

Partitioned tables

Table scan

Hash-based table scan

Partition-based table scan

or

Hash-based table scan


Non-clusted index

Hash-based non-clust

scan

index scan

Hash-based non-clust index scan

ASE Administration Guide - 64

(4) Parallel access SQL Statements

Group by

Aggregates

Union

Order by

Distinct

Select into

Create index

8.2 Parallel scan configuration


(1) Server-wide Parameters

Number of Worker Processes


Parallel Dataserver Worker thread

. 1, Default Parallel

Worker Process Memory


Worker Thread Memory

Max Parallel Degree


Query () Server-Wide . Parallel

Worker thread Parallel (type) Worker


thread
.

Max Scan Parallel Degree

ASE Administration Guide - 65

Hash based access () ServerWide

sp_configure configuration file


sp_configure Parallel Query Parameter .
Number of worker processes
) sp_configure number of work processes, 25
Memory per worker process
Max parallel degree
) sp_configure max parallel degree, n (n : 1 ~ 256)
Max scan parallel degree
) sp_configure max scan parallel degree, n (n : 1 ~ the value of max parallel
degree)

(2) Session Parameters

set command session level options .


Parallel_degree
) set parallel_degree 3
Scan_parallel_degree
) set scan_parallel_degree 2
Process_limit_action

(3)

Statement level

statement-level parallel access setting


table
) select * from huge_table (parallel 1)

ASE Administration Guide - 66

clustered index
) select * from huge_table (index cix parallel 5)
Server-wide session level limit

ASE Administration Guide - 67

9. Transaction

9.1 Transaction
Database SQL SQL Operation (Logical)
.

Data .

Consistency .

All or Nothing.

(1) Transaction Logging

Database Database syslogs Table Logging.

Row Logging.

syslogs Roll Back Roll forward .

(2) Checkpoint

Checkpoint Cache Data Page Log Page Disk .


dirty log dirty data page disk .
Checkpoint Record Log .
transaction interruption .

Checkpoint Recovery Interval SQL Server .


dbo SA Checkpoint .

(3) Write-Ahead Log

Log Page Data Page .

ASE Administration Guide - 68

Server Cache Memory

Log
device

Data
device
data pages

log pages

ASE Administration Guide - 69

Log Page Write .


Commit Tran
Cache Space
Checkpoint
Trigger Fire

Data page Write


Cache Space
Checkpoint

9.2 Recovery

(1) Recovery

Recovery Server Restart Database .


Commit Transaction Database .
Roll forward
Commit Transaction .
Roll back

(2) Recovery Option

recovery interval in minutes = n (per database)


Page Disk .
Checkpoint Log Row ecovery
.

ASE Administration Guide - 70

Dynamic Option.

print recovery information = 1


Recovery transaction Print out.
Static option ASE reboot .

) sp_configure recovery interval in minutes, 3


sp_configure print recovery information, 1

ASE Administration Guide - 71

9.3 User Log Cache (ULC)


(1) user log cache

user connection log record .


.

ULC ASE .

ASE log record user log cache


flush.

(2) User Log Cache Flush?

transaction (commit/rollback)

user log cache space

checkpoint

ASE Administration Guide - 72

10. Backup

10.1 Backup Server


Backup Server
,
H/W .

(1) Backup Server .

SYBASE Backup Server LAN Machine


/ .

GB
(VLDB) .

DBA
.

/
.

Recovery Fault Isolation : Revcovery Page Fault Isolation


.

Point-in-Time Recovery : database recovery .

(2) Backup / Restore

ASE Administration Guide - 73

Database

. Database Back-up

Dump

. Disk Tape

.Database Dump

. Database
Transaction

. Transaction Log Dump

.Database Transaction

Log Dump

. Incremental Dump

Log Device

. Database Dump

Database

. Dump Database Restore

.Database load

Restore

. Media Crash
. Single-User Mode

Transaction

. Dump Transaction Log Restore

Log Restore

. Incremental Load

.Database load .

. Database Restore

(3) Backup / Restore Flow ()

Time

5 PM

Tape1

10 AM
Tape2

5 PM

10 AM

Tape3

Tape4

5 PM
corrupt

|---------------|----------------|----------------|----------------|------------|---------|Create DB

Dump-DB

Dump-Log

Dump-Log

Dump-Log

Restore
Load Tape 1-> load Tape2->load Tape3->load Tape4

5:00 P.M

(4) Recovery

Adaptive Server Enterprise Automatic Recovery .

ASE Administration Guide - 74

50MB

, Adaptive Server
Rollback Rollforward .

Sybase .
.

Restore
.

.
Adaptive Server
.

, (Dirty)
. .

. Adaptive Server
.

ASE Administration Guide - 75

(5) Local Backup Server

SQL Server

database
client1
Backup
Server

(dump)

dump device

dump db ..

machine A

Backup Server dataserver install logical name SYB_BACKUP


,physical name

install

dataserver name_back default.

network name ASEname_back naming.


Syntax : sp_addserver srvname [, {local | null }] {,network_name}
) sp_addserver SYB_BACKUP, null, B_VIOLET(interfaces file define )

Database backup dataserver backupserver


(isql dataserver login SYB_BACKUPsp_who )

(6) Remote Backup Server

ASE Administration Guide - 76

SQL Server

database
client1
Backup
Server

dmp device1

dump db ..
to ...
at machineB

machine A
Backup
Server

(dump)

dump device2
machine B

Remote Backup Local Backup Server Remote Machine Backup Server


.

Local Backup Server .

(7) Dump Device .

Syntax : sp_addumpdevice {tape|disk}, logicalname, physicalname [, tapesize]

) sp_addumpdevice tape, tape3, /dev/nrmt4, 300


* tapesize MB .
** : Tape Dump Physical Device Name Non-Rewind Device
.

10.2 Dump

(1) Dump Database.

Database Transaction Log Backup .

Syntax : dump database database_name to dumpdevice [at b_server_name ]

ASE Administration Guide - 77

[, stripe on stripe_device [at b_server_name] ...


[with { blocksize = number_bytes,
capacity = number_kilobytes,
dumpvolumn = volume_name ,
file = file_name,

[nounload | unload],
[noinit | init]}]]

tape 1 database dump.


dump database pubs2 to /dev/rmt/0mn capacity = 2000000
with = init, unload
tape 2 databaes dump.
dump database pubs2 to /dev/rmt/0mn capacity = 2000000
with = init
dump database pubs3 to /dev/rmt/0mn capacity = 2000000
with = unload

database tape dump .


database tape
dump database pubs2 to /dev/rmt/0mn with capacity = 19000 , init
database dump
Backup Server:6.78.1.1: EXECUTE sp_volchanged
@session_id=8,
@devname=/dev/rmt/0mn,
ASE Administration Guide - 78

@action={PROCED|RETRY|ABORT},
.
.
.
message tape
1> sp_volchanged 8,/dev/rmt/0mn,proceed
2> go
* capacity KB .
* init Tape Initialize Option Dump .
* unload Dump Tape Rewind Option. Tape Dump
nounload(default) Option .
** : Capacity Setting Size Tape Device Size
70% . 30% Overhead .

(2) Dump Transaction.

Transaction Log Backup.

Syntax : dump transaction database_name to dumpdevice [at b_server_name ]

[, stripe on stripe_device [at b_server_name] ...


[with { dumpvolumn = volume_name ,
[nounload | unload], .....
[noinit | init], .....
[truncate_only | no_log | no_truncate] } ]
* truncate_only : Dumping Log
Option .
* no_log

Dumping Log truncate_only Option


Transaction Log .

ASE Administration Guide - 79

Log Device Full truncate_only Option


no_log Option .

Dump Transaction .
Dump transaction mydb to /devnrmt0 with init
Dump transaction mydb with truncate_only.

10.3 Load
(1) Load Database

Synatx : load database database_name from dumpdevice [at b_server_name ]

[, stripe on stripe_device [at b_server_name] ...


[with { [dismount | nodismount],
[nounload | unload] } ]

dump image option


) load database pubs2 from /dev/rmt/0mn with headonly
) load database pubs2 from /dev/rmt/0mn with listonly
) load database pubs2 from /dev/rmt/0mn with listonly = full

** note:
Database .
Load Database , Dump Database .

(2) Load Transaction.

Syntax

load

transaction

database_name

backup_server_name ]

ASE Administration Guide - 80

from

dumpdevice

[at

[, stripe on stripe_device [at backup_server_name ] ...


[with { [dismount | nodismount],
[nounload | unload] } ]

) load transaction pubs2 from /dev/rmt/0mn

8 am

9 am

10 am

10:30 am

Later

Media
failure
Dump
Database

Dump
Tran 1

Dump
Tran 2

Create
Load Load
& Load
Tran 1 Tran 2
Database

ASE Administration Guide - 81

* note:
Transaction load Backup Load .
Dump Database Dump Tran .
Load Database Load Tran .

10.4 Point-in-time Recovery


(1) Point-in-time Recovery ?
ASE11.5.x recovery .

(2) .
, database roll
forward .

(3) Point-in-time Recovery .

Data & log devices .

Truncate log on checkpoint db option .

dump tran with truncate_only log backup .

incremental backup .

(4) Point-in-time Recovery


. (
milliseconds .)

sp_who database log off .


( kill user process .)

database single-user mode .

ASE Administration Guide - 82

1>

user master

2>

go

1>

sp_dboption employees_db single user, true

2>

go

1>

use employees_db

2>

go

1>

checkpoint

2>

go

error database transaction log dump


1>

dump transaction employee_db to /dev/nrmt5

2>

go

database dump load


1>

use master

2>

go

1>

load database employees_db from /dev/nrmt4

2>

go

database dump transaction log load. error


until_time option error transaction log load.

1>

load transaction employee_db from /dev/nrmt5

2>

with until_time = Jan 16 1997 12:45:59:650PM

3>

go

user database single-user mode .


1>

online database

2>

go

1>

sp_dboption employees_db single user, false

2>

go

1>

use employees_db

2>

go

1>

checkpoint

2>

go

ASE Administration Guide - 83

10.5 Backup Miscellaneous


(1) Backup

1. Full Backup : Database backup Transaction Log .

Incremental Backup : Log Backup Transaction Log Backup .

Dump Transaction Log .

User database Backup : Full Backup 1, Log Backup 1 1


.

Incremental Backup 1 1 Full Backup


Log Log Truncate Log Device

master database Backup : Master DB Sever Level , Device, DB,


Login Backup .

(2) Transaction Log release .

Long transaction log space full.


Log space batch job log full
:
isql sp_who database log suspend full database
insert,update,delete .

:
process kill dump tran with truncate_only
batch program run log space database sizing
batch job . log space alter .

Open transaction logholding.


running dump tran log size
log full DBA databae .

ASE Administration Guide - 84

:
select * from master..syslogshold
query results set log hold session

database , holding ,spid .

Transaction)

$user_transaction : begin transaction transaction.


$chained_transaction : ANSI chained mode transaction.

Cained mode program dynamic query user interface


Accept , Performance .
Open transaction log hold Transaction
,

Open transaction Transaction blocking

transaction kill dump tran log


release ..
LTM pointer holding.
$replication_truncation_point : Replication LTM Pointer.
Replication System LTM log replicate data

transaction release . Replication System

LTM log dump tran command log


release .

ASE Administration Guide - 85

11. Monitoring & Troubleshooting SQL Server

11.1 Montoring

(1) Monitoring .

Server Process Monitor OS Utility .


$ showserver : running sybase server processes shell scripts
dataserver,backupserver default display other sybase server

showserver shell scripts processes edit


processes
monitor .
Showserver )
UID

PID PPID C

STIME

sybase10

3759 3758 80

TTY TIME COMD

10:37:08

0:56

/home1/sybase/rel100/bin/dataserver
-d/home1/sybase/rel100/devices/master.dat sybase11

1230 1229 80 5 17

17:11

/home1/sybase/rel110/bin/dataserver
-d/home1/sybase/rel110/master.dat -sSYBASE1

SQL Server Errorlog : DBA monitor ,


server check file.

$SYBASE/install Directory (11.x ver errorlog, 11.5.x servername.log).

SQL Server Start Fatal Error Kernel Error .

ASE Administration Guide - 86

Server Monitor(sp_monitor) : Dataserver currents status


server cpu ,disk i/o,read/write .
)
last_run

current_run

seconds

-------------------------- -------------------------- ----------Sep 30 1998 9:45AM

Sep 30 1998 9:45AM

(1 row affected)
cpu_busy

io_busy

idle

------------------------- ------------------------- ------------------------24(1)-43%

0(0)-0%

packets_received

62485(2)-93%

packets_sent

packet_errors

------------------------- ------------------------- ------------------------18(1)


total_read

15(2)
total_write

0(0)
total_errors

connections

------------------- ------------------- ------------------- -----------------739(3)

315(2)

0(0)

2(0)

ASE Administration Guide - 87

Free Space Used Space

sp_helpdb

sp_helpsegment

sp_spaceused,data_pgs(), rowcnt()

* sp_helpdb db_name : Database .


* sp_spaceused syslogs : Log Log Device .

(2) Threshold Manager

Log Data space warning message Log Dump


. BDA .

last-chance threshold (log segment only).

Data Log free-space Threshold

log segment
free-space thresholds
last-chance threhold
data segment
free-space thresholds

Last-Chance Threshold.

Log Segment , SQL Server last-chance Threshold


Create .

Threshold , SQL Server


User Transaction Abort Suspend.
Errorlog Message .
sp_thresholdaction (system administration guide manual)

ASE Administration Guide - 88

Free-Space Threshold.

Segment free-space threshold .

Syntax : sp_addthreshold database, segment, free_pages, procedure


sp_helpthreshold [segment_name]
)

sp_addthreshold salesdb, data_seg, 200, dataseg_proc


data_seg 200 page free space dataseg_proc .

(3) Database Integrity

Database Object Integrity Monitor

dbcc(Database Consistency

Checker) .

Consistency check VLDB site parallel dbcc .

Parallel dbcc ASE 11.5.x version command.

Parallel dbcc

worker process parallel .

mini lock hold.

standard output database integrity fault .

database .

dbcc procedure .

checkalloc checkdb .

Index consistency .

dbcc checkstorage Setup(manual )

sp_dbcc_plandb resource .

dbccdb database .

ASE Administration Guide - 89

dbccdb cache .

workspace segment .

dbccdb workspace .

sp_dbcc_updateconfig target database .

sp_dbcc_evaluatedb setup .

Consistency Check

dbcc checkdb (db_name)

/* DB Object checktable

*/

dbcc checktable (table_name) /* Table Data Index Page Link Check */

dbcc checkcatalog(db_name)

/*System Table Consistency Check */

Page Allocation Check

dbcc checkalloc(db_name)

dbcc tablealloc(table_name)

/* DB Page Allocation Check */


/* Table Page Allocation Check

*/

dbcc indexalloc(table_name)

/* Index Page Allocation Check

*/

Recovery Database Status Suspect DB dbcc dbrepair


.
Syntax : dbcc dbrepair (database_name, dropdb)

Dbcc Memusage

SQL Server Memory .

ASE Administration Guide - 90

- Output : Code, Kernel, Data Cache, Procedure Size Data Cache


20 Object Size. Procedure Cache 10
Query Plan Size.
-Output

Configuration

Memory

Parameter Total Memory Procedure Cache

.
** note

Data Table or Index 1

Read_Only Table 1

DBCC Object Shared Lock Exclusive Lock


.

(4) Resource Governor

Resource Governor system administrator :

ASE resource

resource limit .

Resource limit login application .

query ASE throughput .

Resource Limit

Enable resource limits sp_configure allow resource limits

Create a named time range sp_add_time_range

Create a resource limit sp_add_resource_limit

ASE Administration Guide - 91

11.2 Troubleshooting
(1) Server Start

Server ip address/hostname .

ip/hostname sybase server start interfaces file

ip/hostname

(sybinit(11.x),dsedit

or

dscp(11.5.x))

Server post process .

netstat an | grep port ASE port process

process

server

port

server

port

(client ) port process kill or OS


reboot.

SQL Server .

00:00000:00000:1998/09/30 10:15:57.25 kernel basis_dlr


00:00000:00000:1998/09/30 10:15:57.32 kernel kdconfig: unable to read primary
master device
00:00000:00000:1998/09/30 10:15:57.32 kernel

kiconfig: read of config block

failed
server start message showserver server
process .

SQL Server (configure option) .

SYBASE,DSQUERY setting .

OS .

shared memory ,asynch i/o sybase server os kernel


.

ASE Administration Guide - 92

Master Device Damage .

master database damage server start


. server start
sybase . master database server
start .

Buildmaster .

Model Database Recovery .

master database corrput .

start

message model databaes .


sybase enginner

buildmaster .

(2) Server Start Access

Password .

sa login login ,password .

Sa password start RUN scripts psa option server


start password .

ASE Administration Guide - 93

Single-User Mode.

server login terminal shutdown server RUN script m


option server start.

User license full.


-

user server connection server


errorlog There are not enough user connections available to start a new
process message loging.

Master database full.

server connection master database master


full server connection .

User database full.

database space database suspend


.

(3) Database

Recovery .

sp_helpdb dbname database status .

Database status offline,suspend status


. long transaction server restart
transaction recovery .
.

User Database permission .

database permission
dbo user database access
guest user database database
.

Database Option single user dbo use only mode.

ASE Administration Guide - 94

database recovery single user mode


database . database
Database 'pubs2' is already open and can only have one user at a time.
message master database sp_dboption pubs2,single,true
database checkpoint single user mode .

Database Loading .

Database Inconsistent.

database
database corrupt . server

errorlog corrupt

messaga .

database corrupt recovery.

(4) User Object

Permissions

dbo objects dbo or sa objects access

) grant all on tablename to username

Space

segment place object segment full


.( device Sp_extendsegment segment
.)

Inconsistency

table corrupt (errorlog) , dbcc tablealloc


recovery .

ASE Administration Guide - 95

Locking

process objects blocking .


1>sp_who

/* SQL Server Connect */

2>go

spid
-----.....
6
7

1>sp_lock

status loginame ....... blk dbname


-------- --------------- ----------sleeping anna
sleeping robby

.....
....

0
6

salesdb
salesdb

cmd
------------SELECT
UPDATE

/* Server Lock */

2>go

spid
----1
6

locktype
--------------Sh_intent
Sh_table_blk

table_id
page
---------------- ------384004399
0
800003316
0

dbname
-------------master
salesdb

sp_who spid 7 blk 6 . spid 7


spid 6 lock .

spid 6 lock sp_lock .


table_id 800003316 Table Shared Lock .

** table_id Table Name System Function


select object_name(table_id)
) select object_name(800003316)

ASE Administration Guide - 96

-> SalesPerson

** Table Name Table ID


select object_id(table_name)

(5) Process Down Hang.

System Problem(Using excessive CPU, paging).

OS bottleneck .

Vmstat ,sar ,platform specific monitor tools system resource monitor


.

Adhoc Query concurrency ASE hang .

online server test .

Multi engines down engine .

Multi engines server engine down


( engine abnormal down
server processes kill ) running
engines server . running engine
processes kill server start .

Long Transaction(cpu , i/o bound ) online server running


server hang .

Database corrupt loop.

dbcc check database .

ASE Administration Guide - 97

12. Administration Topic

12.1 Data Management tools.


(1) Defncopy

Database OS File OS File Database (Definition) Copy.

Copy Definition.
Views, rules, defaults, triggers, stored procedure

Syntax : defncopy

-Uuser_name

-Ppasswd { in | out } file_name db_name

[objectname]

) defncopy -Urobby -Pplayball out deltitle.txt pubs2 deltitle

(2) Bulk Copy

OS File OS File Table Data Copy.

Table Index Trigger bcp in .

Datbase Option select into/bulkcopy True Setting .

Rule, Default .

Data Logging Page Allocation Logging.

Syntax : bcp [[database_name.]owner.] [view_name | table_name [:partition_id]] {in |


out} datafile
[-m maxerrors] [-f formatfile] [-e errfile]
[-F firstrow] [-L lastrow] [-b batchsize]
[-n] [-c] [-t field_terminator] [-r row_terminator]
[-U username] [-P password] [-I interfaces_file] [-S server]
[-a display_charset] [-q datafile_charset] [-z language] [-v]
[-A packet size] [-J client character set]

ASE Administration Guide - 98

[-T text or image size] [-E] [-N] [-X] [-y sybase_dir]


[-g id_start_value] [-R remote_server_principal]

c Option : Data Character Conversion -f Option


. Option DB Data . -r. -t
.

f Option : Data In/Out Format File Option


BCP .

partition table data load partition ID .


) bcp mydb..ptab3:1 in datafile_1
bcp mydb..ptab3:2 in datafile_2
bcp mydb..ptab3:3 in database_3

A Option : Packet Size Option Default Packet Size 512 Byte.

Data BCP In/Out Packet Size

512 Setting.
Packet Size SQL Server Configuration Parameter
maximum Network packet size additional

network memory

J Option : Platform Default Character Set Character Set Server


. SQL Server Client Default Character Set
Server Default Character Set Conversion .

) bcp pubs2..sales out sales.dat -Usa -P -c -t, -SSYBASE


bcp pubs2..sales in sales.dat -Usa -P -fsales.fmt

ASE Administration Guide - 99

Version

Number of
columns

Host file
column
order

Prefix Terminator
length

Server
column name

11.0
4
1 SYBCHAR
2 SYBCHAR
pub_id
3 SYBCHAR
pub_name
3 SYBCHAR
4
city
state
Host file
datatype

0
0
0
0

\t
\t
\t
\n

4
20
20
4

Host file
data length

1
2
4

Server column

< BCP format file >

BCP format File


Table Column OS Data bcp in

10.0
3
1

SYBCHAR 0

""

SYBCHAR 0

30

""

SYBCHAR 0

20

"\n"

pub_id

pub_name
4

ASE Administration Guide - 100

state

OS Data Table Column bcp in

10.0
5
1

SYBCHAR 0

""

pub_id

SYBCHAR 0

80

""

pub_name

SYBCHAR 0

12

""

city

SYBCHAR 0

15

""

SYBCHAR 0

"\n"

state

Table Column OS Data File

10.0
4
1

SYBCHAR 0

""

SYBCHAR 0

40

""

pub_name

SYBCHAR 0

20

""

state

SYBCHAR 0

"\n"

pub_id

city

12.2 Remote Access

Remote Access Server Stored Procedure .

client

Server 1
Request
Response

Server 2
Request

Response
SQL Server
SQL Server
or Open Server
or Open Server

(1) Server

sp_addserver Local remote Server master..sysservers .

Syntax : sp_addserver srvname [, {local | null} ] [, network_name]

sp_addserver SERVER1, local


(local server name Server reboot .)

ASE Administration Guide - 101

sp_addserver GATEWAY, null, VIOLET


( Interfaces File )

(2) Remote Login Mapping

Syntax : sp_addremotelogin remoteserver [, loginame [, remotename]]


mater..sysremotelogins Table Server Login Server Login
.

) sp_addremotelogin Server1, anna, anita

ASE Administration Guide - 102

sysservers
srvname

srvid

....

....

Server1

syslogins
sysremotelogins

suid name

rem.svr rem.user
2
...
...

suid

anita
....
....

3
...
...

Server2 (local)
Server1 (remote)

1
.. .
3
4

sa
....
anna
robby

suid name

Server1.master..syslogins

1
.. .
5
...

sa
....
anita
....

sp_addremotelogin Server3

sysservers
srvname

srvid

....

Server1

Server3

syslogins
sysremotelogins

suid name

rem.svr rem.user
2
3
...

suid

anita
NULL
....

3
-1
...

Server2 (local)
Server3 (remote)

Server1.master..syslogins

suid name
1
.. .
7
8

sa
....
anna
robby

ASE Administration Guide - 103

1
.. .
3
4

sa
....
anna
robby

12.3 Component Integration Services (CIS)

(1)

Component Integration Services (CIS) Sybase non-Sybase


database access . , Oracle DB2 database system
tables, views remote procedure calls non-Sybase data source Sybase
data source access .

ASE & CIS

ASE data source ( Sybase source) access CIS .

CIS data source (non-Sybase) access Extended Enterprise


Option .

(2)

remote server table access .

remote, homogeneous, heterogeneous server table join


.

select into remote server transfer


.


Component Integration Services OmniConnect option install .
sp_configure enable cis, 1 .
Restart ASE
external data source access Direct Connect server gateway
install.
remote objects access server configure.

ASE Administration Guide - 104

12.4 Logical Process Manager

Logical Process Manager (LPM) , system administrator :

login, stored procedure, or application priority control .

login, stored procedure, or application control


.

priority 2)engine engine group task execution .

mixed-workload . , application
application .

13. 12.5

13.1. 12.5.0.1
(1) Device Resize
(2) ASE replicator
(3) Page size tool

ASE Administration Guide - 105

13.2. 12.5.1
(1) automatic database expansion
(2) Dynamic listeners
(3) Dynamic listeners
(4) SQL Deriverd table(in line view)
(5) date time type
(6) database mount/umount
(7) job scheduler
(8) web Service for ASE
(9) cast(),len(),day(),month(),year(),str_replace,newid(),square()
(10) current_date(),current_time()
(11) expand database

13.3. 12.5.2
(1) statement cache
(2) encryption option
(3) backup password
(4) compression backup

ASE Administration Guide - 106

13.4. 12.5.3
(1) cross platform dump and load
(2) top N
(3) getutcdate()

ASE Administration Guide - 107

You might also like