数据迁移:
应用场景:同步正式区与测试区的数据与程序
运行作业adzp555
来源端选择topprd 目的端选择toptst
分别输入两边的oracle的system密码
点击左上方的红色执行键开始迁移
数据恢复:
方法1(推荐):通过oracle的timestamp功能找回数据,适用于误操作时间较相近
假设删除料件基础表的料件101-000001,企业号为10
delete from imaa_t where imaaent=10 and imaa001=‘101-000001’
资料删除后,现在进行恢复:
1.select sysdate from dual 记录当前时间
2.create table imaa_t_bak as select * from imaa_t where 1=2 创建空表(参考原表结构)
3.select * from dadata.imaa_t as of timestamp to_timestamp('2021-11-15 10:00:00','yyyy-mm-dd hh24:mi:ss') where imaaent=10 and imaa001=‘101-000001’ 推算原表的删除时间,如果找不到,就再往前推时间
4.insert into imaa_t_bak select * from dadata.imaa_t as of timestamp to_timestamp('2021-11-15 10:00:00','yyyy-mm-dd hh24:mi:ss') 把查到的资料写入到备份表
5.insert into imaa_t select * from imaa_t_bak where imaa_t_bak.imaa001 not in (select imaa001 from imaa_t) 从备份表恢复到原表资料审查后确认是被删除的资料,把备份表的资料插入到原来被删除的实体表
方法2:从系统的备份数据提取,一般备份的数据存放在u3/backup/*/目录下,*为具体的星期
1.创建用户 (pl/sql中使用system执行) 命名test的库
create user test identified by test default tablespace dsdata temporary tablespace temp;
grant tiptop to test;
alter user test profile tiptop;
grant create any table to test;
grant drop any table to test;
grant create procedure to test;
grant unlimited tablespace to test;
2.解压文件(linux中使用root执行) 解压系统备份包
gunzip -d dsdata.dmp.gz
chmod -R 777 /u3/backup/Mon (用root执行赋权限)
3.恢复表数据到该用户(linux中使用tiptop执行)
imp system/tiptop100@topprd file=/u3/backup/Mon/dsdata.dmp fromuser=dsdata touser=test tables=imaa_t;
4.test库中把数据更新到dsdata库,可根据实际情况添加限定条件,毕竟是整个表的数据
insert into dsdata.imaa_t select * from test.imaa_t where test.imaa001 not in ((select imaa001 from dsdata.imaa_t))