GBase 8a
运维管理
文章

oracle周期同步增量数据到gbase8a

发表于2025-10-13 15:14:2834次浏览4个评论

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 ; /

评论

登录后才可以发表评论
用户头像
GBase用户28017发表于 9个月前
学习ING。
用户头像
levvel发表于 7个月前
我看好你哟!
用户头像
levvel发表于 2个月前
给你点个赞
半夏发表于 2个月前
学习了