本课指导您通过以下步骤建立 SQL Anywhere 统一数据库:
创建统一数据库和模式。
运行 MobiLink 安装脚本。
为统一数据库定义 ODBC 数据源。
在此过程中,您将使用 Sybase Central 的 [创建数据库向导] 来创建统一数据库。
选择 [开始] » [程序] » [SQL Anywhere 11] » [Sybase Central]。
选择 [工具] » [SQL Anywhere 11] » [创建数据库]。
在 [欢迎] 页面上,单击 [下一步]。
单击 [下一步]。
在 [将主数据库文件保存到以下文件] 字段中键入 C:\MLmon\cons.db。单击 [下一步]。
请按照 [创建数据库向导] 中的说明进行操作并接受缺省值。
单击 [完成]。
统一数据库模式包括 Product 表,其中存储硬件产品的名称和数量。
在 Sybase Central 的左窗格中,右击 [cons - DBA],然后选择 [文件] » [打开 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 ) go insert 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 |
运行 MobiLink 安装脚本来添加 MobiLink 需要的系统对象。
在 [SQL 语句] 窗格中,键入:
read "C:\Program Files\SQL Anywhere 11\MobiLink\setup\syncsa.sql" |
使用 SQL Anywhere 11 驱动程序为 cons 数据库定义 ODBC 数据源。
选择 [开始] » [程序] » [SQL Anywhere 11] » [ODBC 管理器]。
单击 [用户 DSN] 选项卡,然后单击 [添加]。
在 [名称] 列表中,单击 [SQL Anywhere 11]。单击 [完成]。
在 [SQL Anywhere 11 的 ODBC 配置] 窗口中,进行以下操作:
单击 [ODBC] 选项卡。
在 [数据源名] 字段中,键入 sa_cons。
单击 [登录] 选项卡。
在 [用户 ID] 字段键入 DBA。
在 [口令] 字段中键入 sql。
单击 [数据库] 选项卡。
在 [服务器名] 字段中键入 cons。
在 [数据库文件] 字段中键入 C:\MLmon\cons.db。
单击 [确定]。
单击 [确定]。
有关使用 dbinit 命令行实用程序创建统一数据库的信息,请参见初始化实用程序 (dbinit)或第 3 课:为同步创建脚本。
有关统一数据库(包括非 SQL Anywhere RDBMS)的详细信息,请参见MobiLink 统一数据库。
有关 Interactive SQL 的详细信息,请参见使用 Interactive SQL。
Copyright © 2009, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.1 |