Flashback Table and foreign key constraints in Oracle PL/SQL

Source: Internet
Author: User

We know that the Flashback Table can restore the drop Table from the recycle bin, but not everything about the Table can be returned by Flashback, such as foreign key constraints.

  1. Duzz $ scott @ orcl>Create TableD (deptno numberPrimary Key, Deptname varchar2 (20 ));
  2. TableCreated.
  3. Elapsed: 00:00:00. 28
  4. Duzz $ scott @ orcl>Create TableE (empno numberPrimary Key, Ename varchar2 (20), deptno number,ConstraintFk_deptForeign Key(Deptno)ReferencesD (deptno ));
  5. TableCreated.
  6. Elapsed: 00:00:00. 39
  7. Duzz $ scott @ orcl>Select*FromD;
  8. DEPTNO DEPTNAME
  9. ---------------------
  10. 10 IT
  11. 20 HR
  12. Elapsed: 00:00:00. 03
  13. Duzz $ scott @ orcl>Select*FromE;
  14. EMPNO ENAME DEPTNO
  15. ---------------------------------
  16. 1 KING 10
  17. 2 HARI 20
  18. Elapsed: 00:00:00. 00
  19. Duzz $ scott @ orcl>SelectConstraint_name, constraint_type, table_nameFromUser_constraintsWhereTable_nameIn('D','E');
  20. CONSTRAINT_NAME CON TABLE_NAME
  21. ------------------------------------
  22. SYS_C005553 P D
  23. SYS_C005554 P E
  24. FK_DEPT R E
  25. Elapsed: 00:00:00. 00
  26. Duzz $ scott @ orcl>Insert IntoEValues(2,'Cott', 10 );
  27. Insert IntoEValues(2,'Cott', 10)
  28. *
  29. ERRORAtLine 1:
  30. ORA-00001:Unique Constraint(SCOTT. SYS_C005554) violated
  31. Elapsed: 00:00:00. 01
  32. Duzz $ scott @ orcl>Insert IntoEValues(3,'Ing', 55 );
  33. Insert IntoEValues(3,'Ing', 55)
  34. *
  35. ERRORAtLine 1:
  36. ORA-02291: integrityConstraint(SCOTT. FK_DEPT) violated-parentKey NotFound
  37. Elapsed: 00:00:00. 01
  38. Duzz $ scott @ orcl>Drop TableE;
  39. TableDropped.
  40. Elapsed: 00:00:00. 09
  41. Duzz $ scott @ orcl> flashbackTableEToBeforeDrop;
  42. Flashback complete.
  43. Elapsed: 00:00:00. 10
  44. Duzz $ scott @ orcl>SelectConstraint_name, constraint_type, table_nameFromUser_constraintsWhereTable_nameIn('D','E');
  45. CONSTRAINT_NAME CON TABLE_NAME
  46. --------------------------------------
  47. SYS_C005553 P D
  48. BIN $ MzYoteesSWeEWRlJ P E
  49. Afkfcg = $0
  50. Elapsed: 00:00:00. 00
  51. Duzz $ scott @ orcl>Insert IntoEValues(2,'Cott', 10 );
  52. Insert IntoEValues(2,'Cott', 10)
  53. *
  54. ERRORAtLine 1:
  55. ORA-00001:Unique Constraint(SCOTT. BIN $ MzYoteesSWeEWRlJAfkfcg ==$ 0) violated
  56. Elapsed: 00:00:00. 01
  57. Duzz $ scott @ orcl>Insert IntoEValues(3,'Ing', 55 );
  58. 1 row created.
  59. Elapsed: 00:00:00. 00
  60. Duzz $ scott @ orcl>

In addition, tables with Fine-Grained Auditing and Virtual Private Database policies cannot be recovered. Please refer to the official Oracle Flashback description:

  • 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 ies 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

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.