0
点赞
收藏
分享

微信扫一扫

GBASE南大通用技术分享:Oracle周期同步增量数据到南大通用GBase 8a操作解析

本文主要介绍由Oracle同步增量数据到南大通用GBase 8a数据库的操作过程。


1、在oracle库中创建带主键的表。

create table a(a int, b varchar2(10),c int);

insert into a values(1,'a',1);

insert into a values(2,'b',2);

insert into a values(3,'c',3);

insert into a values(4,'d',4);

alter table a add constraint a_key primary key(a);

2、在gbase8a中创建相同表结构的表。

create table a(a int, b varchar2(10),c int);

3、在oracle库中创建触发器

alter table a add constraint a_key primary key(a);

--创建快照表 a_kz

create table a_kz(id integer,optype varchar2(15),keyid varchar2(64),primary key(id));

--创建快照表序列 a_kz_seq

create sequence a_kz_seq increment by 1 start with 1 nomaxvalue nocycle;

--创建insert触发器。当向源表中插入记录时触发

create or replace trigger a_ins_tr after insert on a for each row begin insert into a_kz values(a_kz_seq.nextval,T,:new.keyid); end ; /

--创建update触发器。当更新源表中的记录时触发

create or replace trigger a_upd_tr after update on a_kz for each row begin insert into a_kz values(a_kz_seq.nextval,'U',:old.keyid); end;/

--创建delete触发器。当删除源表中饿记录时触发

create or replace trigger a_del_tr after delete on a for each row begin insert into a_kz values(a_kz_seq.nextval,'D',:old.keyid); end ; /


举报

相关推荐

0 条评论