Linux下创建Sybase数据库
在Linux环境中,Sybase数据库的创建有以下几步:
第一步:创建数据设备和日志设备
在数据库服务器中,每个数据库最好拥有自己独立的数据设备和日志设备,特别是要与master库的设备分开,这样有利于日后的管理。
首先用sa用户登录数据库:isql -U sa -P sapassword -S TESTDB //这里数据库服务器名称是TESTDB
然后用 disk init 命令,创建数据设备:
disk init name = 'mbss_data01',physname = '/u01/sybase15/product/data/mbss_data01.dat',size = '1024M', directio = true, skip_alloc = true
disk init name = 'mbss_data02',physname = '/u01/sybase15/product/data/mbss_data02.dat',size = '1024M', directio = true, skip_alloc = true
disk init name = 'mbss_data03',physname = '/u01/sybase15/product/data/mbss_data03.dat',size = '1024M', directio = true, skip_alloc = true
disk init name = 'mbss_data04',physname = '/u01/sybase15/product/data/mbss_data04.dat',size = '1024M', directio = true, skip_alloc = true
disk init name = 'mbss_data05',physname = '/u01/sybase15/product/data/mbss_data05.dat',size = '1024M', directio = true, skip_alloc = true
go
disk init name = 'mbss_index01',physname = '/u01/sybase15/product/data/mbss_index01.dat',size = '1024M', directio = true, skip_alloc = true
disk init name = 'mbss_index02',physname = '/u01/sybase15/product/data/mbss_index02.dat',size = '1024M', directio = true, skip_alloc = true
disk init name = 'mbss_index03',physname = '/u01/sybase15/product/data/mbss_index03.dat',size = '1024M', directio = true, skip_alloc = true
disk init name = 'mbss_index04',physname = '/u01/sybase15/product/data/mbss_index04.dat',size = '1024M', directio = true, skip_alloc = true
disk init name = 'mbss_index05',physname = '/u01/sybase15/product/data/mbss_index05.dat',size = '1024M', directio = true, skip_alloc = true
go
创建日志设备:
disk init name = 'mbss_log01',physname = '/u01/sybase15/product/data/mbss_log01.dat',size = '1024M', directio = true, skip_alloc = true
disk init name = 'mbss_log02',physname = '/u01/sybase15/product/data/mbss_log02.dat',size = '1024M', directio = true, skip_alloc = true
go
第二步:创建数据库
数据设备和日志设备创建完后,就可以基于这些设备来创建数据库了:
CREATE DATABASE mbss01
ON mbss_data01 = '1024M'
, mbss_data02 = '1024M'
, mbss_data03 = '1024M'
, mbss_data04 = '1024M'
, mbss_data05 = '1024M'
, mbss_index01 = '1024M'
, mbss_index02 = '1024M'
, mbss_index03 = '1024M'
, mbss_index04 = '1024M'
, mbss_index05 = '1024M'
LOG ON mbss_log01 = '1024M'
,mbss_log02 = '1024M'
GO
第三步:创建数据库的区段
创建区段,就可以对大数据量数据的表和索引进行分区管理,以增加数据的访问速度,所以创建数据的区段很必要。
use mbss01
go
exec sp_addsegment 'SEGMENT_PART01', 'mbss01', 'mbss_data01'
exec sp_addsegment 'SEGMENT_PART02', 'mbss01', 'mbss_data02'
exec sp_addsegment 'SEGMENT_PART03', 'mbss01', 'mbss_data03'
exec sp_addsegment 'SEGMENT_PART04', 'mbss01', 'mbss_data04'
exec sp_addsegment 'SEGMENT_PART05', 'mbss01', 'mbss_data05'
go
exec sp_addsegment 'SEGMENT_INDEX01', 'mbss01', 'mbss_index01'
exec sp_addsegment 'SEGMENT_INDEX02', 'mbss01', 'mbss_index02'
exec sp_addsegment 'SEGMENT_INDEX03', 'mbss01', 'mbss_index03'
exec sp_addsegment 'SEGMENT_INDEX04', 'mbss01', 'mbss_index04'
exec sp_addsegment 'SEGMENT_INDEX05', 'mbss01', 'mbss_index05'
go