→Tags:分区 同步 时间 基于 实现 解析 employee id 数据库 name ←
一 建库及数据源
1.建立数据库
在cmd下执行,中央数据库consol
D:/mobilink>dbinit consol |
两个远程数据库zhou1 zhou2
D:/mobilink>dbinit zhou1D:/mobilink>dbinit zhou2 |
2.启动服务
在命令行下敲dbsrv9,在弹出的对话框中选择数据库文件,并敲入相应的服务名, 按照这种方式启动consol zhou1 zhou2 服务。
3.建立odbc数据源
二 处理中央数据库
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)commitgo-- 加入脚本版本及脚本 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 前面不要有空格。为了保持格式,这里是有空格的,执行时要注意。
1 2 3 下一页>> weq北方站长站
weq北方站长站
共有 0 位网友发表了评论 此处只显示部分留言 点击查看完整评论页面