ITPub博客

首页 > Linux操作系统 > Linux操作系统 > oracle表的复制转移

oracle表的复制转移

原创 Linux操作系统 作者:renjiubao 时间:2010-06-10 23:09:26 0 删除 编辑

1)、采用database link方法拷贝数据(适用数据量不是太大并更新频繁的表,网络要通并且索引不是很多)

方法:在备机上创建数据库的database link:首先在备机的netmgr上建立数据库连接,然后使用create public database link linux_oracle connect to scott identified by tiger using 'linux_oracle'就可以使用主库上的表了。

查看数据库链接表:dba_db_links

2)、exp/imp

3)、触发器(自动化)

现在假设有两个数据库A,B,B库中的备用表需要和A库中的住表同步数据。主表和备用表表名相同(也可以不同),都叫a
1。首先建立在A库所在的机器建立访问B库的网络服务名bak,用NET-MANAGER完成
2。创建PUBLIC DATABASE LINK :CREATE PUBLIC DATABASE LINK bak USING 'bak',以sys/system用户创建
3。在B库用户下创建私有DATABASE LINK(同PUBLIC DATABASE LINK名称相同),要具有CREATE DATABASE LINK权限。指定用户和密码 
CREATE DATABASE LINK bak CONNECT TO topup IDENTIFIED BY smartpaytopup
4。创建触发器
create or replace trigger topup_transaction_trigger
after insert or update on topup_transaction
begin
merge into topup_transaction@bak t2
using topup_transaction t1 on(
t2.tx_date=t1.tx_date)
when matched then
update set t2.b=t1.b
when not matched then
insert (a,b)  values(t1.a,t1.b);
end;


create or replace trigger topup_transaction_trigger2
after delete on topup_transaction
begin
delete from topup_transaction@bak
where tx_date in(
select a from topup_transaction@bak
minus
select a from t);
end sync_data2;

4)。采用物化视图()

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/8541256/viewspace-664947/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2010-05-20

  • 博文量
    28
  • 访问量
    29468