sqlserver2008数据同步gbase8s
测试场景:sqlserver2008数据同步gbase8s
1、表结构
SQLserver:create table t1(a int,b varchar(10),c datetime);
GBase8s:Create table t1(a int,b varchar(10),c datetime year to second);
2、查询sqlserver是否开始cdc
Select is_cdc_enabled from sys.databases where name = 'sync_8s';
3、开启库级cdc操作
执行命令exec sync_8s.sys.sp_cdc_enable_db;开启库级CDC
4、同步工具增加sqlserver和gbase8s数据源,选择需要同步的表,启动同步任务
5、增量同步
Insert into t1 values(1,’a’,’2022-03-13 18:15:30’);
Insert into t1 values(2,’b’,’2022-03-13 18:15:30’);
Insert into t1 values(3,’c’,’2022-03-13 18:15:30’);
Insert into t1 values(4,’d’,’2022-03-13 18:15:30’);
Insert into t1 values(5,’e’,’2022-03-13 18:15:30’);
6、更新同步
update t1 set b = 'aaa' where a = 1;
update t1 set b = 'bbb' where a = 2;
update t1 set b = 'ccc' where a = 3;
update t1 set b = 'ddd' where a = 4;
update t1 set b = 'eee' where a = 5;
7、删除同步
delete from t1 where a =1;
delete from t1 where a =2;
delete from t1 where a =3;
delete from t1 where a =4;
delete from t1 where a =5;
8、新增列同步
(1)停止同步任务
(2)源端新增列:alter table t1 add d varchar(10);
(3)手动添加新增表列信息到cdc任务
EXEC sys.sp_cdc_disable_table
@source_schema = N'dbo',
@source_name = N't1',
@capture_instance = N'dbo_t1';
EXEC sys.sp_cdc_enable_table
@source_schema = N'dbo',
@source_name = N't1',
@role_name = 'NULL',
@capture_instance = N'dbo_t1';
(4)目标端新增列:alter table t1 add d varchar(10);
(5)手动在数据源连接中选择新增加列字段内容
(6)同步任务-选择新增列的表-库表配置-刷新目标端表信息-手动进行新增列对应关系
(7)启动同步任务
9、删除列同步
(1)停止同步任务
(2)源端删除列:alter table t1 drop column d;
(3)目标端删除列:alter table t1 drop d;
(4)元数据目录-(分别对源端和目标端执行)
选择删除列的表-字段-曾选字段-清除垃圾字段
(5)同步任务-选择新增列的表-库表配置-刷新目标端表信息-手动进行新增列对应关系
(6)启动同步任务
10、源端增加表
(1)增加新表
源端:create table t2(a int,b varchar(10),c datetime);
目标端:create table t2(a int,b varchar(10),c datetime year to second);
(2)数据源连接(源端和目标端分别通过库表选择增加需要同步的新表)
(3)任务管理-复制同步-打开任务-选择源库表
(4)启动任务
11、源端删除表
(1)停止同步任务
(2)数据源连接(源端和目标端分别通过库表选择删除不需要同步的新表)
(3)任务管理-复制同步-选择源库表
删除不需要同步的表
(4)启动任务
评论
热门帖子
- 12025-12-01浏览数:182763
- 22023-05-09浏览数:25057
- 42023-09-25浏览数:18525
- 52020-05-11浏览数:17528