Oracle操作

复制数据库表数据

先清除ht2上的所有cstp数据=====

--删除所有的 TABLE_NAME like 'FICSTP_%' 的表数据
begin
      --先禁用外键约束
  for tableName in (select 'alter table '||table_name||' disable constraint '||constraint_name as disable_fk from user_constraints where constraint_type='R' and TABLE_NAME like 'FICSTP_%' and STATUS = 'ENABLED') loop
    execute immediate tableName.disable_fk  ; 
  end loop ;
  --再删除表数据
   for tableName_2 in (select table_name from user_tables where table_name like 'FICSTP_%') loop
    execute immediate 'delete from ' || tableName_2.table_name ; 
  end loop ;
  --最后启用外键约束
    for tableName_3 in (select 'alter table '||table_name||' enable constraint '||constraint_name as enable_fk from user_constraints where constraint_type='R' and TABLE_NAME like 'FICSTP_%' and STATUS = 'DISABLED') loop
      execute immediate tableName_3.enable_fk  ; 
  end loop ;
end ;
--删除所有的 TABLE_NAME like 'FXCSTP_%' 的表数据
begin
      --先禁用外键约束
  for tableName in (select 'alter table '||table_name||' disable constraint '||constraint_name as disable_fk from user_constraints where constraint_type='R' and TABLE_NAME like 'FXCSTP_%' and STATUS = 'ENABLED') loop
    execute immediate tableName.disable_fk  ; 
  end loop ;
  --再删除表数据
   for tableName_2 in (select table_name from user_tables where table_name like 'FXCSTP_%') loop
    execute immediate 'delete from ' || tableName_2.table_name ; 
  end loop ;
  --最后启用外键约束
    for tableName_3 in (select 'alter table '||table_name||' enable constraint '||constraint_name as enable_fk from user_constraints where constraint_type='R' and TABLE_NAME like 'FXCSTP_%' and STATUS = 'DISABLED') loop
      execute immediate tableName_3.enable_fk  ; 
  end loop ;
end ;

delete from CSTPSENTOUT ;

====复制ht的数据到ht2上 需要在ht用户打开的sql界面上操作 ht能访问ht2 =====

insert into  ht2.FICSTP_CRSELFDEALT  (select * from  ht.FICSTP_CRSELFDEALT where tradedatetime = ‘那一天的日期’);
insert into  ht2.FICSTP_下一张表  (select * from  ht.FICSTP_CRSELFDEALT where tradedatetime = ‘那一天的日期’);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值