从备份恢复数据

Restore data from back up

我正在尝试将转储文件中的数据恢复到没有重复值的 table 中。为此,我将转储文件中的数据放入临时 table。现在我需要比较临时 table 和现有 table.After 的内容,原始 table 中不存在的任何行都应该从临时 table 添加到其中。

declare
table_name varchar(30);
poid_id0 au_account_t.poid_id0%type;
CURSOR row_pointer  is
SELECT MIN(au_account_t) as table_name,POID_ID0
FROM
(
SELECT 'au_account_t' as au_account_t, au_account_t.POID_ID0
FROM au_account_t
UNION ALL
SELECT 'au_account_t_temp' as au_account_t_temp, au_account_t_temp.POID_ID0
FROM au_account_t_temp
) tmp
GROUP BY POID_ID0
HAVING COUNT(*) = 1
ORDER BY POID_ID0;
begin
open row_pointer;
loop
fetch row_pointer into table_name,poid_id0;
EXIT WHEN row_pointer%notfound;
dbms_output.put_line(poid_id0);
insert into au_account_t(poid_id0)values (poid_id0); 
end loop;
close row_pointer;
end ;

我需要比较所有列而不仅仅是主键 poid_id0 并将整行插入主键 table。

您可以使用多列子查询来完成这个任务,例如。

insert into emp (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO)
select EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO from temp_emp
where (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO)
not in (select EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO
 from emp)