Professional Documents
Culture Documents
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
(4) .......................................................................................................... 22
2. ............................................................................................. 25
2.1 Device ..............................................................................................25
(1) Disk Init.................................................................................................................. 25
(2) Default Device ....................................................................................................... 27
(3) Device ............................................................................................................ 27
(4) Device ............................................................................................................ 28
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
5. AUDITING ........................................................................................... 49
5.1 Auditing ..............................................................................................49
(1) Audit .............................................................................................................. 49
(2) Audit system install and management .................................................................... 49
(3) Audit system Query ............................................................................................... 50
9. TRANSACTION ............................................................................. 68
9.1 Transaction .........................................................................................68
(1) Transaction Logging ....................................................................... 68
(2) Checkpoint ............................................................................................................ 68
(3) Write-Ahead Log ................................................................................................... 68
1.
1.1 ASE (Adaptive Server Enterprise)
(1) ASE
Integrity security
Department of Defense Trusted Computer System Evaluation Criteria"(TCSEC)
B1
High Availability
Cluster SMP .
,
.
Cost-based Optimizer.
Optimizer Query Plan
. , optimize query .
ASE , .
, , .
ASE Login account .
ASE .
.
ASE .
ASE (Auditing) .
System table
- sysobjects
- syslogs
- sysprotects
- sysprocedures
- sysusers
- syssegments
- sysroles
- sysalternates
- systypes
- syscolumns
- sysindexes
- sysdepends
- syskeys
- sysgams
- systhreshold
- sysreferences
- sysattributes
- syspartitions
, System Table
.
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 .
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 ]
2> go
S DSQUERY ASE .
Isql SQL
Reset :
vi
: isql vi .
quit
: isql .
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
ASE (stop)
ASE .
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 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
(2) ASE
(3) ASE
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
(4) ASE
$SYBASE/install/errorlog
ASE login
ASE (env )
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 .
min
max
config_value run_value
----------------------------------------------------------------remote access
Static Option
: ASE .
(3) Configuration
sp_configure Configuration .
ASE Configuration
($SYBASE/<servername>.cfg) .
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>]
(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
/* */
/**/
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
75202
75776
lock promotion
2.
2.1 Device
ASE .
sysdevices
name
c
d
.... phyname
data_dev1 .....disk1d
data_dev1
logical name
physical name
sp_helpdevice : Device .
(3) Device
Device Device .
Syntax : sp_dropdevice device_name
(4) Device
2.2 Mirroring
Write.
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
disk2
) disk mirror
name = data_dev1,
mirror = /dev/rsd3d
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 .
3. (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]
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
.
DB .
Mirroring .
(3) (Ownership)
Database . Ownership DB
.
Database .
Syntax : sp_helpdb [database_name]
Database .
Option
abort tran on log full : Last-chance threshold
.
allow nulls by default : NULL NULL
.
dbo use only
: dbo Database
ddl in tran
: DDL
read only
: Database
single user
: Database
: Database Checkpoint
Truncate 5
unique auto_identity
3.2 Database
Alter Database dbo sa Database .
expansion
expansion
OR
data_dev1
data_dev1
data_dev2
(3) Database
Database .
(3) Segments
(4) Segments
sp_dropsegment
) sp_dropsegment default, salesdb, data_dev3
(5) Segments
sp_helpsegment [segname]
(6) Segments
segment device
(7) sp_extentsegment
Query
. ASE 11.5
11.X Release
Heap Insertion Point
I/O
11.5 Release
Query (,
Worker Process ).
bcp in
load balancing .
I/O Contention
.
.
I/O .
Fragment . Query I/O
Contention , .
I/O Balancing
Load Balancing .
.
Pre-11.5 :
System tables
Work tables
Temporary tables
( .)
11.5 :
System tables
( .)
(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
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
4. Access (Controlling)
4.1 User
(1) Database Owner(dbo)
Database User .
Checkpoint, dbcc .
(2) sa Login
Database Owner .
(3) Role
disk storage
SA grant/revoke
ASE login
Password
Audit system
ASE Connect .
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 .
syslogins
name
claire
robby
master
user3db
user2db
user1db
sysusers
sysusers
name
name
claireb
robby
fredp
maryj
(4) Group
sp_addgroup engineering
,
sp_adduser robert, bob, engineering
or
sp_changegroup engineering, bob
public Group .
(5) Role
Login Role .
select show_role()
else
print You have SA role.
Return 0
Grant
Syntax :
Revoke
Syntax :
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 }
Revoke
Syntax :
. db_id( )
. user_id( )
. db_name( )
. user_name( )
. proc_role( )
select suser_id( )
select suser_id(fred)
. sp_helprotect object_name
. sp_helprotect user_name
. suser_name( )
5. Auditing
5.1 Auditing
Security system (sybsecurity)
database object .
login monitoring
login .
(1) Audit
ASE Level
Database Level : grant, revoke, truncate, drop, load, create, alter, bcp, bind, unbind,
dbaccess, dump
Object Level
User Level
: cmdtext
auditinit install
) sp_audit create,all,db1,both
Contents of sysaudits
event
eventmod
eventtime
sequence
xactid
loginname
dbname
objname
objowner
extrainfo
6. Buffer Manager
Performance I/O .
Buffer manager (contention) .
DSS OLTP Memory .
Memory Memory .
Named Cache
OLTP
Hash
2K
OPTIMIZER
DSS
16 K
OLTP DSS .
: Size 512K .
cache size memory .
Binding Entity Cache .
Database Binding Master Database .
Object Cursor Open, Dirty Read .
syslogs Binding cache Log-only Cache .
DSS .
sp_poolconfig
cache_name,
pool_size
from_io_sizeK]
[P|K|M|G],
to_io_sizeK
[,
Syntax : select select_list from [ {tablename} [(indid | index indname [prefetch size]
[lru | mru] )] [holdlock | noholdlock] where ......
Default MRU on .
S
DS
T
OL
MRU
Regular
Strategy
Wash
Marker
DS
LRU
MRU
Strategy
Data Pages
in Use
7.3 Joincount
8. Parallel Processing
Adaptive Server 11.5 query parallel access
. parallel query
table partitioning
scan width
partition skew
Process
1
Access
Process
2
Process
3
Process
4
- Thread
- Thread
Result Set(bucket)
Merge
- Bucket
Result set Merge
Merge mechanism
.
, I/O throughput
data
pages
Partition 1
Partition 2
Hash scans
Partition 3
Partition 4
: partition tables
hash
.
ii . Clustered index hash scan .
iii . optimizer
Level 0
data
pages
Clustered index
Scan type
Unpartitioned tables
Partitioned tables
Table scan
Non-clusted index
Hash-based non-clust
scan
index scan
none
Unpartitioned tables
Partitioned tables
Table scan
or
Hash-based non-clust
scan
index scan
Group by
Aggregates
Union
Order by
Distinct
Select into
Create index
. 1, Default Parallel
(3)
Statement level
clustered index
) select * from huge_table (index cix parallel 5)
Server-wide session level limit
9. Transaction
9.1 Transaction
Database SQL SQL Operation (Logical)
.
Data .
Consistency .
All or Nothing.
Row Logging.
(2) Checkpoint
Log
device
Data
device
data pages
log pages
9.2 Recovery
(1) Recovery
Dynamic Option.
ULC ASE .
transaction (commit/rollback)
checkpoint
10. Backup
GB
(VLDB) .
DBA
.
/
.
Database
. Database Back-up
Dump
. Disk Tape
.Database Dump
. Database
Transaction
.Database Transaction
Log Dump
. Incremental Dump
Log Device
. Database Dump
Database
.Database load
Restore
. Media Crash
. Single-User Mode
Transaction
Log Restore
. Incremental Load
.Database load .
. Database Restore
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
50MB
, Adaptive Server
Rollback Rollforward .
Sybase .
.
Restore
.
.
Adaptive Server
.
, (Dirty)
. .
. Adaptive Server
.
SQL Server
database
client1
Backup
Server
(dump)
dump device
dump db ..
machine A
install
SQL Server
database
client1
Backup
Server
dmp device1
dump db ..
to ...
at machineB
machine A
Backup
Server
(dump)
dump device2
machine B
10.2 Dump
[nounload | unload],
[noinit | init]}]]
@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 .
Dump Transaction .
Dump transaction mydb to /devnrmt0 with init
Dump transaction mydb with truncate_only.
10.3 Load
(1) Load Database
** note:
Database .
Load Database , Dump Database .
Syntax
load
transaction
database_name
backup_server_name ]
from
dumpdevice
[at
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
* note:
Transaction load Backup Load .
Dump Database Dump Tran .
Load Database Load Tran .
(2) .
, database roll
forward .
incremental backup .
1>
user master
2>
go
1>
2>
go
1>
use employees_db
2>
go
1>
checkpoint
2>
go
2>
go
use master
2>
go
1>
2>
go
1>
2>
3>
go
online database
2>
go
1>
2>
go
1>
use employees_db
2>
go
1>
checkpoint
2>
go
:
process kill dump tran with truncate_only
batch program run log space database sizing
batch job . log space alter .
:
select * from master..syslogshold
query results set log hold session
Transaction)
11.1 Montoring
(1) Monitoring .
PID PPID C
STIME
sybase10
3759 3758 80
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
current_run
seconds
(1 row affected)
cpu_busy
io_busy
idle
0(0)-0%
packets_received
62485(2)-93%
packets_sent
packet_errors
15(2)
total_write
0(0)
total_errors
connections
315(2)
0(0)
2(0)
sp_helpdb
sp_helpsegment
sp_spaceused,data_pgs(), rowcnt()
log segment
free-space thresholds
last-chance threhold
data segment
free-space thresholds
Last-Chance Threshold.
Free-Space Threshold.
dbcc(Database Consistency
Checker) .
Parallel dbcc
database .
dbcc procedure .
checkalloc checkdb .
Index consistency .
sp_dbcc_plandb resource .
dbccdb database .
dbccdb cache .
workspace segment .
dbccdb workspace .
sp_dbcc_evaluatedb setup .
Consistency Check
/* DB Object checktable
*/
dbcc checkcatalog(db_name)
dbcc checkalloc(db_name)
dbcc tablealloc(table_name)
*/
dbcc indexalloc(table_name)
*/
Dbcc Memusage
Configuration
Memory
.
** note
Read_Only Table 1
ASE resource
resource limit .
Resource Limit
11.2 Troubleshooting
(1) Server Start
Server ip address/hostname .
ip/hostname
(sybinit(11.x),dsedit
or
dscp(11.5.x))
process
server
port
server
port
SQL Server .
failed
server start message showserver server
process .
SYBASE,DSQUERY setting .
OS .
Buildmaster .
start
buildmaster .
Password .
Single-User Mode.
(3) Database
Recovery .
database permission
dbo user database access
guest user database database
.
Database Loading .
Database Inconsistent.
database
database corrupt . server
errorlog corrupt
messaga .
Permissions
Space
Inconsistency
Locking
2>go
spid
-----.....
6
7
1>sp_lock
.....
....
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
-> SalesPerson
OS bottleneck .
Copy Definition.
Views, rules, defaults, triggers, stored procedure
Syntax : defncopy
-Uuser_name
[objectname]
Rule, Default .
512 Setting.
Packet Size SQL Server Configuration Parameter
maximum Network packet size additional
network memory
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
10.0
3
1
SYBCHAR 0
""
SYBCHAR 0
30
""
SYBCHAR 0
20
"\n"
pub_id
pub_name
4
state
10.0
5
1
SYBCHAR 0
""
pub_id
SYBCHAR 0
80
""
pub_name
SYBCHAR 0
12
""
city
SYBCHAR 0
15
""
SYBCHAR 0
"\n"
state
10.0
4
1
SYBCHAR 0
""
SYBCHAR 0
40
""
pub_name
SYBCHAR 0
20
""
state
SYBCHAR 0
"\n"
pub_id
city
client
Server 1
Request
Response
Server 2
Request
Response
SQL Server
SQL Server
or Open Server
or Open Server
(1) Server
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
1
.. .
3
4
sa
....
anna
robby
(1)
(2)
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.
mixed-workload . , application
application .
13. 12.5
13.1. 12.5.0.1
(1) Device Resize
(2) ASE replicator
(3) Page size tool
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
13.4. 12.5.3
(1) cross platform dump and load
(2) top N
(3) getutcdate()