【Oracle】闪回表
语法:
FLASHBACK TABLE [ schema. ] table [, [ schema. ] table ]...
TO { { { SCN | TIMESTAMP } expr| RESTORE POINT restore_point}
[ { ENABLE | DISABLE } TRIGGERS ]| BEFORE DROP [ RENAME TO table ]} ;
注 flashback table 为 ddl
1.创建测试表T1,并插入数据
SCOTT@lgr> create table t1 (x number(2),d date);
Table created.
SCOTT@lgr> insert into t1 (x) values(1);
1 row created.
SCOTT@lgr> insert into t1 values(2,sysdate);
1 row created.
SCOTT@lgr> commit;
Commit complete.
SCOTT@lgr> select * from t1;
X D
---------- -------------------
1
2 2017-02-19,10:53:41
2.记录当前的时间
SCOTT@lgr> select sysdate from dual;
SYSDATE
-------------------
2017-02-19,10:54:49
3.删除T1表中的一条数据
SCOTT@lgr> delete t1 where x=2;
1 row deleted.
SCOTT@lgr> commit;
Commit complete.
SCOTT@lgr> select * from t1;
X D
---------- -------------------
1
4.此时对表进行闪回,会出现错误。原因很明显,因为表T1没有开启行移动
SCOTT@lgr> flashback table t1 to timestamp to_date('2017-02-19,10:54:49','yyyy-mm-dd,hh24:mi:ss');
flashback table t1 to timestamp to_date('2017-02-19,10:54:49','yyyy-mm-dd,hh24:mi:ss')
*
ERROR at line 1:
ORA-08189: cannot flashback the table because row movement is not enabled
SCOTT@lgr> select table_name,row_movement from user_tables where table_name='T1';
TABLE_NAME ROW_MOVE
------------------------------ --------
T1 DISABLED
5.对表T1开启行移动
SCOTT@lgr> alter table t1 enable row movement;
Table altered.
6.对表T1进行基于时间点的闪回操作
SCOTT@lgr> flashback table t1 to timestamp to_date('2017-02-19,10:54:49','yyyy-mm-dd,hh24:mi:ss');
Flashback complete.
SCOTT@lgr> select * from t1;
X D
---------- -------------------
1
2 2017-02-19,10:53:41
最新文章
- python学习笔记(基础四:模块初识、pyc和PyCodeObject是什么)
- Java开发web的几种开发模式
- Windows下安装paramiko
- TinyFox在VS2015上的调试器
- CI调试
- hdu 3157 Crazy Circuits 有源汇和下界的最小费用流
- DHCP服务器
- Struts2 学习笔记17 I18N国际化
- bootbox api
- OJ2236“孤单数”题目报告
- Java爬虫爬取网站电影下载链接
- git使用kdiff3合并乱码问题
- 关于使用python ~取反操作符带出的一系列问题
- Java参数是值传递还是引用传递?
- Android NDK学习(四):C/C++层调用JAVA
- JGit与远程仓库链接使用的两种验证方式(ssh和https)
- Shell编程-08-Shell中的循环语句
- Android SDK目录及版本号区别
- Extjs CheckboxSelectionModel 置为无效 选择触发事件
- List of Chromium Command Line Switches(命令行开关集)——官方指定命令行更新网址
热门文章
- ansible - 基本用法
- python json结构
- C#关键字详解第四节
- PatentTips - Zero voltage processor sleep state
- node.js 如何完美的从命令行接收参数所传递进来的值
- [bzoj1592][Usaco09Feb]Making the Grade 路面修整_动态规划
- Spring MVC SessionAttributes ModelAttribute注解
- N天学习一个linux命令之kill
- CF #329 D
- jQuery toast message 地址 使用