首页 > 解决方案 > 客户快照

问题描述

我想创建客户表的快照,并在拍摄快照时添加参考日期。

select * from customer_dump;
select * from customer_snapshot;
select count(*) into b 
from user_tables 
where table_name = upper('customer_snapshot_dump');
if b = 1 then
  execute immediate 'drop table customer_snapshot_dump purge';
end if;
EXECUTE IMMEDIATE 'create table customer_snapshot_dump as (select sysdate as SNAPSHOT_DATE,* from customer_snapshot)';
EXECUTE IMMEDIATE 'drop table customer_snapshot purge';
EXECUTE IMMEDIATE
'create table customer_snapshot as (SELECT * FROM customer_dump
UNION
SELECT * FROM customer_snapshot_dump)';
end;

但是 snapshot_date 只会使其合并所有数据。如何在联合中忽略快照日期但仍将其添加到表中?

标签: oracleplsql

解决方案


推荐阅读