Oracle PL/SQL之Flashback Table与外键约束
2011-08-25 23:55
423 查看
我们知道 Flashback Table可以把drop掉的表从回收站里恢复回来,但是并不是关于该表的所有东西都能被Flashback回来,比如外键约束。
除此之外,带有细粒度审计(Fine-Grained Auditing )和虚拟专用数据库策略(Virtual Private Database policies)的表也不可恢复的哦,请看Oracle官方的Flashback说明:
A table and all of its dependent objects (indexes, LOB segments, nested tables, triggers, constraints and so on) go into the recycle bin together, when you drop the table. Likewise, when you perform Flashback Drop, the objects are generally all retrieved together.
It is possible, however, that some dependent objects such as indexes may have been reclaimed due to space pressure. In such cases, the reclaimed dependent objects are not retrieved from the recycle bin.
Due to security concerns, tables which have Fine-Grained Auditing (FGA) and Virtual Private Database (VPD) policies defined over them are not protected by the recycle bin.
Partitioned index-organized tables are not protected by the recycle bin.
The recycle bin does not preserve referential constraints on a table (though other constraints will be preserved if possible). If a table had referential constraints before it was dropped (that is, placed in the recycle bin), then re-create any referential constraints after you retrieve the table from the recycle bin with Flashback Drop.
REF:
http://download.oracle.com/docs/cd/B19306_01/backup.102/b14192/flashptr004.htm
duzz$scott@orcl>create table d(deptno number primary key, deptname varchar2(20)); Table created. Elapsed: 00:00:00.28 duzz$scott@orcl>create table e(empno number primary key, ename varchar2(20), deptno number, constraint fk_dept foreign key (deptno) references d(deptno)); Table created. Elapsed: 00:00:00.39 duzz$scott@orcl>select * from d; DEPTNO DEPTNAME ---------- ----------- 10 IT 20 HR Elapsed: 00:00:00.03 duzz$scott@orcl>select * from e; EMPNO ENAME DEPTNO ---------- ------------- ---------- 1 KING 10 2 HARI 20 Elapsed: 00:00:00.00 duzz$scott@orcl>select constraint_name,constraint_type,table_name from user_constraints where table_name in ('D','E'); CONSTRAINT_NAME CON TABLE_NAME -------------------- --- ------------- SYS_C005553 P D SYS_C005554 P E FK_DEPT R E Elapsed: 00:00:00.00 duzz$scott@orcl>insert into e values(2,'COTT',10); insert into e values(2,'COTT',10) * ERROR at line 1: ORA-00001: unique constraint (SCOTT.SYS_C005554) violated Elapsed: 00:00:00.01 duzz$scott@orcl>insert into e values(3,'ING',55); insert into e values(3,'ING',55) * ERROR at line 1: ORA-02291: integrity constraint (SCOTT.FK_DEPT) violated - parent key not found Elapsed: 00:00:00.01 duzz$scott@orcl>drop table e; Table dropped. Elapsed: 00:00:00.09 duzz$scott@orcl>flashback table e to before drop; Flashback complete. Elapsed: 00:00:00.10 duzz$scott@orcl>select constraint_name,constraint_type,table_name from user_constraints where table_name in ('D','E'); CONSTRAINT_NAME CON TABLE_NAME -------------------- --- --------------- SYS_C005553 P D BIN$MzYoteesSWeEWRlJ P E Afkfcg==$0 Elapsed: 00:00:00.00 duzz$scott@orcl>insert into e values(2,'COTT',10); insert into e values(2,'COTT',10) * ERROR at line 1: ORA-00001: unique constraint (SCOTT.BIN$MzYoteesSWeEWRlJAfkfcg==$0) violated Elapsed: 00:00:00.01 duzz$scott@orcl>insert into e values(3,'ING',55); 1 row created. Elapsed: 00:00:00.00 duzz$scott@orcl>
除此之外,带有细粒度审计(Fine-Grained Auditing )和虚拟专用数据库策略(Virtual Private Database policies)的表也不可恢复的哦,请看Oracle官方的Flashback说明:
A table and all of its dependent objects (indexes, LOB segments, nested tables, triggers, constraints and so on) go into the recycle bin together, when you drop the table. Likewise, when you perform Flashback Drop, the objects are generally all retrieved together.
It is possible, however, that some dependent objects such as indexes may have been reclaimed due to space pressure. In such cases, the reclaimed dependent objects are not retrieved from the recycle bin.
Due to security concerns, tables which have Fine-Grained Auditing (FGA) and Virtual Private Database (VPD) policies defined over them are not protected by the recycle bin.
Partitioned index-organized tables are not protected by the recycle bin.
The recycle bin does not preserve referential constraints on a table (though other constraints will be preserved if possible). If a table had referential constraints before it was dropped (that is, placed in the recycle bin), then re-create any referential constraints after you retrieve the table from the recycle bin with Flashback Drop.
REF:
http://download.oracle.com/docs/cd/B19306_01/backup.102/b14192/flashptr004.htm
相关文章推荐
- Oracle PL/SQL之Flashback Table与外键约束
- Oracle PL/SQL之Flashback Table与外键约束
- oracle pl/sql Nested Table
- sql语句增加表单字段ALTER TABLE ADD 增加多个字段 外键约束
- Import data from EXCEL to Oracle table with PL/SQL Developer
- Oracle PL/SQL之嵌套表(Nested Table)
- ORACLE 存储过程及TABLE里的数据用PL/SQL备份及用PLUS SQL还原
- oracle外键约束,无法truncate table的时候
- PL/SQL 删除外键 ORA-02443: 无法删除约束条件-不存在的约束条件
- Oracle PL/SQL之嵌套表(Nested Table)
- Oracle PL/SQL开发基础(第一弹:创建表和创建约束)
- Oracle PL/SQL语言初级教程之完整性约束
- mysql oracle sql文件备份恢复问题(外键约束导致导入sql需要按顺序)
- Oracle PL/SQL之嵌套表(Nested Table)
- Oracle PL/SQL开发基础(第二弹:使用数据字典视图查看表约束)
- Oracle PL/SQL之处理index不连续的table类型变量
- Oracle:SQL语句--对表的操作——添加外键约束
- MySQL创建外键约束的报错Error : Can't create table '#sql-534_185' (errno: 150)
- Oracle PL/SQL之处理index不连续的table类型变量
- oracle学习之路(四) ---------PL/SQL 表,二维数组(TABLE)