新客网WWW.XKER.COM:致力做中国最专业的网络学院!
学院: 操作系统 - 网络应用 - 服务器 - 网络安全 - 工具软件 - 办公软件 - Web开发 - 数据库 - 网页设计 - 图形图像 - 媒体动画 - 硬件学堂 - 存储频道 - QQ专区
您的位置:首页 > 软件开发 > 数据库 > Sybase教程 > 正文:解析MobiLink实现基于时间戳的分区同步

解析MobiLink实现基于时间戳的分区同步

新客网 XKER.COM 2007-08-06 来源: Sybase 收藏本文

一 建库及数据源

1.建立数据库

在cmd下执行,中央数据库consol

 

D:\mobilink>dbinit consol

两个远程数据库zhou1 zhou2

 

D:\mobilink>dbinit zhou1
D:\mobilink>dbinit zhou2

 

 

2.启动服务

在命令行下敲dbsrv9,在弹出的对话框中选择数据库文件,并敲入相应的服务名, 按照这种方式启动consol zhou1 zhou2 服务。

 

3.建立odbc数据源

 

consol zhou1 zhou2

二 处理中央数据库

1.dbisql 连接到consol数据库

执行以下语句:

-- 建表,owner列作为分区用, active 用作逻辑删除 last_modified 用作时间戳同步,只在中央数据库需要这三列,远程数据库不需要。

 

create table employee(id int NOT NULL PRIMARY KEY, 
name varchar(128), 
owner varchar(128), 
active int default 1, last_modified 
timestamp DEFAULT timestamp)

-- 录入数据       
insertinto employee(id, name, owner, 
active ) values (1, '小桥', 'zhou1', 1)
insert into employee(id, name, owner, 
active ) values (2, '流水', 'zhou2', 1)
insert into employee(id, name, owner, 
active ) values (3, '人家', 'zhou1', 1)
commit
go

-- 加入脚本版本及脚本
  call ml_add_table_script( 'version1', 
'employee', 'upload_insert', 'insert into 
employee(id, name) values (?,?)' )
  go
  call ml_add_table_script( 'version1', 
'employee', 'upload_update', 'update employee 
set name=? where id = ?' )
  go
  call ml_add_table_script( 'version1', 
'employee', 'upload_delete', 'delete from 
employee where id = ?' )
  go
  call ml_add_table_script( 'version1', 
'employee', 'download_cursor','select id, 
name from employee where last_modified > ? 
and owner = ? and active = 1' )
  go
  call ml_add_table_script( 'version1', 
'employee', 'download_delete_cursor', 
'select id from employee  where last_modified>? 
and (owner !=? or active = 0)' )
  go

-- 注意go 前面不要有空格。为了保持格式,这里是有空格的,执行时要注意。

共3页: 上一页 [1] [2] [3] 下一页
收藏】 【评论】 【推荐】 【投稿】 【打印】 【关闭
发表评论
要记得去论坛讨论,点击注册新会员匿名评论
评论内容:不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
阅读排行
随机推荐
实用信息推荐