Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1042491
  • 博文数量: 239
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 3618
  • 用 户 组: 普通用户
  • 注册时间: 2012-11-12 13:17
文章分类

全部博文(239)

文章存档

2021年(1)

2016年(1)

2015年(30)

2014年(91)

2013年(116)

分类: LINUX

2014-01-30 18:24:12

闪回数据归档

在USERS表空间中创建一个能够将"旧"数据保存1年的数据归档,取名"FDA1",操作者必须拥有"flashback_archive administer"系统权限
SQL> create flashback archive fda1 tablespace users retention 1 year;


Flashback archive created.


SQL> create flashback archive default fda_dedault tablespace users retention 1 year;


Flashback archive created.


使用"flashback archive"子句在特定的表上启用闪回数据归档功能了,比如让hr.employees使用fda1,从此该表的修改历史将保留1年。
SQL> alter table hr.employees flashback archive fda1;


Table altered.




授予hr用户执行"flashback archive"对象权限
SQL> grant flashback archive on fda1 to hr;


Grant succeeded.


让hr.departments使用默认的FDA,从此改表历史也将保留1年
SQL> alter table hr.departments flashback archive;


Table altered.




在创建新表时也可以执行所使用的闪回数据归档
SQL> create table oe.inventory (id number,product_id number,supplier_id number) flashback archive fda1;


Table created.


使用"no flashback archive"子句可以关闭特定表上的闪回数据归档功能,执行该命令需要"flashback archive administer"系统权限
SQL> alter table oe.inventory no flashback archive;


Table altered.


比如在启用归档功能至少7个月之后再查看hr.employees表7个月前的内容(由于我的数据库没有7个月,我用7分钟表示)
select * from hr.employees as of timestamp (systimestamp - interval '7' minute);


创建fda2时限制其空间限制为20G
SQL> create flashback archive fda2 tablespace users quota 20G retention 1 year;


Flashback archive created.


闪回数据归档中的历史数据当然可以被手工清除,比如清除归档fda1中的10分钟之前的数据
SQL> alter flashback archive fda1 purge before timestamp (systimestamp - interval '10' minute);


Flashback archive altered.


或者全部清除
SQL> alter flashback archive fda1 purge all;


Flashback archive altered.
阅读(923) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~