Sybase ASE 15.5 利用自带scripts脚本创建演示数据库pubs2
来源:互联网 发布:淘宝客新建定向计划 编辑:程序博客网 时间:2024/06/18 02:10
脚本路径在$SYBASE/$SYBASE_ASE路径下,数据库默认在pubs在default设备上,初始大小4~28不等,如脚本31到38行所示:
1: /* %Z% generic/sproc/%M% %I% %G% */
2:3: /*
4: ** raiserror Messages for installpubs2 [Total 3]5: **6: ** 19527, "The '%1!' database cannot be created. Terminating the installation."7: ** 19528, "The '%1!' database does not exist. Terminating the installation."8: ** 19529, "Cannot open database '%1!'. Check the availability of this database and retry the installation."9: */10:11: /*
12: ** 4/12/98 added 'on default = 3' to CREATE DATABASE13: ** moved CREATE INDEX statements after INSERTs14: */15:16: /* 7/17/98 added use master at start, use pubs2 at end */
17: /* installpubs2 1.0 4/5/91 */
18: /* has primary and foreign keys, plus text and image tables*/
19: use master20: go21: set nocount on22:23: if exists (select * from master.dbo.sysdatabases
24: where name = "pubs2")
25: begin26: drop database pubs227: end28: go29: print 'Creating the "pubs2" database'
30:31: if (@@maxpagesize = 1024 * 2)
32: create database pubs2 on default = 4
33: else if (@@maxpagesize = 1024 * 4)34: create database pubs2 on default = 7
35: else if (@@maxpagesize = 1024 * 8)36: create database pubs2 on default = 14
37: else if (@@maxpagesize = 1024 * 16)38: create database pubs2 on default = 28
39: else
40: create database pubs2 on default
41: go42:43: if not exists (select * from master.dbo.sysdatabases
44: where name = "pubs2")
45: begin46: /*
47: ** 19527, "The '%1!' database cannot be created. Terminating the installation."48: */49: raiserror 19527, "pubs2"
50: select syb_quit()51: end52: go53:54: set dateformat mdy55: go56: sp_dboption pubs2, "trunc log on chkpt", true57: go58: use pubs259: go60: if (db_name() != "pubs2")61: begin62: /*
63: ** 19529, "Cannot open database '%1!'. Check the availability of this database and retry the installation."64: */65: raiserror 19529, "pubs2"
66: select syb_quit()67: end68: go69: checkpoint70: go71: if exists (select * from master.dbo.sysdatabases
72: where name = "pubs2")
73: begin74: execute sp_addtype id, "varchar(11)", "not null"75: execute sp_addtype tid, "varchar(6)", "not null"76: end77: else
78: begin79: /*
80: ** 19528, "The '%1!' database does not exist. Terminating the installation."81: */82: raiserror 19528, "pubs2"
83: select syb_quit()84: end85: go86: if exists (select * from master.dbo.sysdatabases
87: where name = "pubs2")
88: begin89: create table authors
在实际生产中我们一般不会把生产库放在master设备上,于是乎先建立专门用户数据段的设备和日志段的设备:
用shell>isql -U sa -P <password> -S <服务器名> 登录后执行如下命令
use mastergodisk init name = 'pubs2data',
physname = '/db2bodb1/sybasedata/pubs2data.dat',
size = '1024M', dsync = true, skip_alloc = true
gouse mastergodisk init name = 'pubs2log',
physname = '/db2bodb1/sybaselog/pubs2log.dat',
size = '512M', dsync = true, skip_alloc = true
go
创建了两个设备,传建完成后,库默认创建在default设备上,修改下创建在自己自定义的数据设备和日志设备上:
1: /* %Z% generic/sproc/%M% %I% %G% */
2:3: /*
4: ** raiserror Messages for installpubs2 [Total 3]5: **6: ** 19527, "The '%1!' database cannot be created. Terminating the installation."7: ** 19528, "The '%1!' database does not exist. Terminating the installation."8: ** 19529, "Cannot open database '%1!'. Check the availability of this database and retry the installation."9: */10:11: /*
12: ** 4/12/98 added 'on default = 3' to CREATE DATABASE13: ** moved CREATE INDEX statements after INSERTs14: */15:16: /* 7/17/98 added use master at start, use pubs2 at end */
17: /* installpubs2 1.0 4/5/91 */
18: /* has primary and foreign keys, plus text and image tables*/
19: use master20: go21: set nocount on22:23: if exists (select * from master.dbo.sysdatabases24: where name = "pubs2")
25: begin26: drop database pubs227: end28: go29: print 'Creating the "pubs2" database'
30:31: if (@@maxpagesize = 1024 * 2)32: create database pubs2 on pubs2data = 1024 log on pubs2log=51233: else if (@@maxpagesize = 1024 * 4)34: create database pubs2 on pubs2data = 1024 log on pubs2log=51235: else if (@@maxpagesize = 1024 * 8)36: create database pubs2 on pubs2data = 1024 log on pubs2log=51237: else if (@@maxpagesize = 1024 * 16)38: create database pubs2 on pubs2data = 1024 log on pubs2log=51239: else40: create database pubs2 on pubs2data = 1024 log on pubs2log=51241: go42:43: if not exists (select * from master.dbo.sysdatabases44: where name = "pubs2")
45: begin46: /*
47: ** 19527, "The '%1!' database cannot be created. Terminating the installation."48: */49: raiserror 19527, "pubs2"
50: select syb_quit()51: end52: go53:54: set dateformat mdy55: go56: sp_dboption pubs2, "trunc log on chkpt", true
57: go58: use pubs259: go60: if (db_name() != "pubs2")
61: begin62: /*
63: ** 19529, "Cannot open database '%1!'. Check the availability of this database and retry the installation."64: */65: raiserror 19529, "pubs2"
66: select syb_quit()67: end68: go69: checkpoint70: go71: if exists (select * from master.dbo.sysdatabases72: where name = "pubs2")
73: begin74: execute sp_addtype id, "varchar(11)", "not null"75: execute sp_addtype tid, "varchar(6)", "not null"76: end77: else78: begin79: /*
80: ** 19528, "The '%1!' database does not exist. Terminating the installation."81: */82: raiserror 19528, "pubs2"
83: select syb_quit()84: end85: go86: if exists (select * from master.dbo.sysdatabases87: where name = "pubs2")
88: begin89: create table authors
利用修改后的脚本传建数据库
shell> cd $SYBASE/$SYBASE_ASE/scripts
shell>isql -U sa -P <password> -S <服务器名> -i installpubs2,创建成功,如日志。
-bash-3.00$ isql -U sa -P ××××× -S ××××××× -i installpubs2Creating the "pubs2" databaseCREATE DATABASE: allocating 65536 logical pages (1024.0 megabytes) on disk'pubs2data' (65536 logical pages requested).CREATE DATABASE: allocating 32768 logical pages (512.0 megabytes) on disk'pubs2log' (32768 logical pages requested).Processed 39 allocation unit(s) out of 384 units (allocation page 68096). 10%completed.Processed 77 allocation unit(s) out of 384 units (allocation page 13568). 20%completed.Processed 116 allocation unit(s) out of 384 units (allocation page 20224). 30%completed.Processed 154 allocation unit(s) out of 384 units (allocation page 26624). 40%completed.Processed 192 allocation unit(s) out of 384 units (allocation page 81152). 50%completed.Processed 231 allocation unit(s) out of 384 units (allocation page 84480). 60%completed.Processed 269 allocation unit(s) out of 384 units (allocation page 46336). 70%completed.Processed 308 allocation unit(s) out of 384 units (allocation page 52992). 80%completed.Processed 346 allocation unit(s) out of 384 units (allocation page 59392). 90%completed.Processed 384 allocation unit(s) out of 384 units (allocation page 98048). 100%completed.00:00:00000:00023:2015/11/23 11:05:25.94 server Timestamp for database 'pubs2' is (0x0000, 0x00001366).Database 'pubs2' is now online.Database option 'trunc log on chkpt' turned ON for database 'pubs2'.Running CHECKPOINT on database 'pubs2' for option 'trunc log on chkpt' to takeeffect.(return status = 0)Type added.(return status = 0)Type added.(return status = 0)New primary key added.(return status = 0)New primary key added.(return status = 0)New primary key added.(return status = 0)New primary key added.(return status = 0)New primary key added.(return status = 0)New primary key added.(return status = 0)New primary key added.(return status = 0)New primary key added.(return status = 0)New primary key added.(return status = 0)New primary key added.(return status = 0)New primary key added.(return status = 0)New foreign key added.(return status = 0)New foreign key added.(return status = 0)New foreign key added.(return status = 0)New foreign key added.(return status = 0)New foreign key added.(return status = 0)New foreign key added.(return status = 0)New foreign key added.(return status = 0)New foreign key added.(return status = 0)New foreign key added.(return status = 0)New foreign key added.(return status = 0)Default bound to column.(return status = 0)Default bound to column.(return status = 0)Default bound to column.(return status = 0)Rule bound to table column.(return status = 0)Rule bound to table column.(return status = 0)Rule bound to table column.(return status = 0)(return status = 0)-bash-3.00$
还可以用下面的脚本插入,带图像的数据:
-bash-3.00$ isql -U sa -P ×××× -S ×××× -i installpix2Database option 'select into/bulkcopy/pllsort' turned ON for database 'pubs2'.Running CHECKPOINT on database 'pubs2' for option 'select into/bulkcopy/pllsort'to take effect.(return status = 0)(1 row affected)(1 row affected)(1 row affected)(1 row affected)(1 row affected)(1 row affected)(1 row affected)(1 row affected)Return parameters:txts------------------
0x0000000000002094(1 row affected)(1 row affected)Return parameters:txts------------------
0x00000000000020a6(1 row affected)(1 row affected)Return parameters:txts------------------
0x00000000000020b7(1 row affected)(1 row affected)Return parameters:txts------------------
0x00000000000020cb(1 row affected)(1 row affected)Return parameters:txts------------------
0x00000000000020dc(1 row affected)(1 row affected)Return parameters:txts------------------
0x00000000000020f3Database option 'select into/bulkcopy/pllsort' turned OFF for database 'pubs2'.Running CHECKPOINT on database 'pubs2' for option 'select into/bulkcopy/pllsort'to take effect.(return status = 0)The script installpix is complete.No further action on your part is required.-bash-3.00$
over!
参考文章:Sybase官网初始pubs2设备
0 0
- Sybase ASE 15.5 利用自带scripts脚本创建演示数据库pubs2
- Sybase ASE 基础(2)创建数据库
- 利用Sybase Central简单操作Sybase ASE数据库
- 通过JDBC访问Sybase ASE 15.5数据库
- Sybase ase 数据库日常维护
- Sybase ASE各系统数据库
- linux sybase ase 数据库恢复
- [c++]VS2008利用自带的sql2005 express创建数据库
- sybase创建用户数据库的脚本
- 关于Sybase ASE数据库的命名来历
- 理解Sybase ASE数据库中的索引
- Sybase ASE重建以及修复数据库日志
- 理解Sybase ASE数据库中的索引
- SAP ERP升级数据库Sybase ASE
- Sybase ASE 基础(3)数据库设置
- Sybase ASE 基础(5)数据库优化
- 利用系统自带脚本utlsampl.sql创建scott用户及样本数据
- 通过ADO.NET访问Sybase ASE 15.5数据库datetime字段的小问题
- extern 和 extern“C”
- Android_GestureDetector 手势相关
- __BEGIN_DECLS 和__END_DECLS
- HDU2126 二维背包
- 协议用法
- Sybase ASE 15.5 利用自带scripts脚本创建演示数据库pubs2
- ffplay注解
- jQuery ajax方法详解
- 使用 GitHub, Jekyll 打造自己的免费独立博客
- Myeclipse2014中,新建部署Maven项目
- list合并
- 使用BroadcastReceiver进行短信监控
- 跨文档消息传输之postMessage()
- 白手起家学习数据科学 ——可视化数据(一)