oracle的sql使用方式记录

1.创建相同的表
create table USER_temp as select from USER;   --数据结构都取
create table USER_temp as select from USER where 1=0; --只取表结构,不取数据 
2.sql记录
表结构和字段顺序完全一样 直接:insert into tab1 select * from tab2即可插入一个表的数据到另一张表里
3.oracle闪回数据
--(1)查询 修改数据之前时间
select * from t_v_axle_info as of timestamp to_timestamp('2019-08-07 14:10:03','yyyy-mm-dd hh24:mi:ss');
以下三种闪回方式:
--(2.1)直接使用
insert into tab1 select * from t_v_axle_info as of timestamp to_timestamp('2019-08-07 14:10:03','yyyy-mm-dd hh24:mi:ss');
--(2.2)使用正确数据时间戳 进行数据闪回
FLASHBACK TABLE t_v_axle_info TO TIMESTAMP to_timestamp('2019-08-07 14:10:03','yyyy-mm-dd hh24:mi:ss')
--(2.3)使用行移动功能
----  (2.3.1) 拿到SCN 号
SELECT timestamp_to_scn(to_timestamp('2019-08-07 14:10:03','yyyy-mm-dd hh24:mi:ss')) SCN FROM t_v_axle_info
----  (2.3.2) 开启行移动功能(对于未开启行移动功能的才去执行该行)
ALTER TABLE CT_FIN_RiskItem ENABLE ROW MOVEMENT
----  (2.3.3) 执行闪回即可
FLASHBACK TABLE CT_FIN_RiskItem TO SCN 30336255
4.drop表可以通过flashback 恢复表
flashback table tablename to before drop;
 
原文地址:https://www.cnblogs.com/zyanrong/p/11315241.html