本课将指导您完成如下步骤,以设置 Adaptive Server Anywhere 统一数据库:
创建统一数据库和模式。
为统一数据库定义 ODBC 数据源。
在这一步中,使用 Sybase Central 的 [创建数据库] 向导创建统一数据库。
创建 Adaptive Server Anywhere RDBMS
启动 Sybase Central。
选择 [开始] > [程序] > [Sybase SQL Anywhere 9] > [Sybase Central]。
出现 Sybase Central。
在 Sybase Central 中,选择 [工具] > [Adaptive Server Anywhere 9] > [创建数据库]。
屏幕上会出现 [创建数据库] 向导。单击 [下一步]。
保留缺省值 [在这台计算机上创建数据库]。单击 [下一步]。
输入数据库文件名和路径。例如,输入以下语句:
C:\temp\cons.db
请按照向导中的其余说明进行操作,除下面的项外,均接受缺省值。
选择 4096 字节页面大小。
4K 页面大小可提高许多环境的性能。
单击 [完成] 连接到 Sybase Central 中的新数据库。
统一数据库模式包括 Product 表,该表存储硬件产品的名称和数量。
将 Product 表添加到统一模式中
启动 Interactive SQL。
在 Sybase Central 的左窗格中,选择 cons - DBA 数据库。从 [文件] 菜单选择 [打开 Interactive SQL]。
显示 Interactive SQL。
安装 Product 表。
在 Interactive SQL 中执行以下命令。
/* the Product table */
create table Product (
name varchar(128) not null primary key,
quantity integer,
last_modified timestamp default timestamp
)
goinsert into Product(name, quantity) values ( 'Screwmaster Drill', 10); insert into Product(name, quantity) values ( 'Drywall Screws 10lb', 30); insert into Product(name, quantity) values ( 'Putty Knife x25', 12); go
安装用于冲突解决的临时表。
在第 6 课:为冲突检测和解决创建脚本中,您将编写脚本,当冲突发生时,将值插入这些表中。
/* the Product_old table */
create table Product_old (
name varchar(128) not null primary key,
quantity integer,
last_modified timestamp default timestamp
)
go
/* the Product_new table */
create table Product_new (
name varchar(128) not null primary key,
quantity integer,
last_modified timestamp default timestamp
)
go校验是否成功创建了表。
例如,在 Interactive SQL 中,执行以下命令验证 Product 表的内容。
select * from Product
使用 Adaptive Server Anywhere 9.0 驱动程序为 cons 数据库定义 ODBC 数据源。
为统一数据库定义 ODBC 数据源
启动 ODBC 管理器:
从 [开始] 菜单,选择 [程序] > [SQL Anywhere 9] > [Adaptive Server Anywhere] > [ODBC 管理器]。
此时将出现 [ODBC 数据源管理器]。
在 [用户 DSN] 选项卡上,单击 [添加]。
出现 [创建新数据源] 对话框。
选择 [Adaptive Server Anywhere 9.0] 并单击 [完成]。
出现 [Adaptive Server Anywhere 9 的 ODBC 配置] 对话框。
在 [ODBC] 选项卡上键入数据源名 asa_cons。在 [逻辑] 选项卡上,在 [用户 ID] 中键入 DBA,在 [口令] 中键入 SQL。在 [数据库] 选项卡上,在 [服务器名] 中键入 cons。
单击 [确定] 以添加数据源。
单击 [确定] 关闭 ODBC 管理器。
您还可以使用 dbinit 命令行实用程序创建统一数据库。有关详细信息,请参见使用 dbinit 命令行实用程序创建数据库或第 2 课:设置远程 Adaptive Server Anywhere 数据库。
有关统一数据库(包括非 ASA RDBMS)的详细信息,请参见统一数据库。
有关 Interactive SQL 的详细信息,请参见 Interactive SQL 实用程序。
有关创建 ODBC 数据源的详细信息,请参见数据源实用程序。
SQL Anywhere Studio 9.0.2
版权所有 © 1989–2005 Sybase, Inc. 部分版权所有 © 2001–2005 iAnywhere Solutions, Inc. 保留所有权利。