Restrictions on Oracle flashback table Deletion

Source: Internet
Author: User

Oracle 10 Gb has provided the recycle bin function similar to windows. When you delete a table, it is not directly deleted, but moved to the recycle bin. If you need to retrieve the original table from the recycle bin, you can use flashback to delete a table to quickly retrieve the deleted table without importing the original table from the backup! However, this recycle bin function is also prerequisite. You can not use flashback to delete tables under any circumstances. In summary, in 10 Gb, tables cannot be deleted using flashback in the following scenarios, if there is any improvement on the 11g, you can refer to the method in this article to test it! By the way, the recycle bin adopts a fifo, first-in-first-out mechanism! For example, if there are two tables with the same name in the recycle bin, you can find the table that was first flashed back Based on the sequence of the deletion time. Therefore, the "rename to" option is provided for the "flashback Delete table" command;

1: the recycle bin function is not enabled (this does not need to be tested)
2: The table's storage tablespace cannot be system
3: The purge parameter cannot be included when the table is deleted.
4: when there is space pressure
5: fine-grained audit is enabled on the table
6: VPD is enabled for the table.

I. test whether the table space is stored as system flash-back Deletion
1.1 create a test user and grant corresponding permissions to enable the database recycle bin function.

 
 
  1. [oracle@dg53 ~]$ sqlplus /nolog  
  2. SQL*Plus: Release 10.2.0.1.0 - Production on Thu Feb 16 16:48:44 2012  
  3. Copyright (c) 1982, 2005, Oracle.  All rights reserved.  
  4.  
  5. SQL> conn /as sysdba  
  6. Connected.  
  7.  
  8. SQL> create user test identified by "123456" default tablespace users account unlock;  
  9. User created.  
  10.  
  11. SQL> grant resource,connect to test;  
  12. Grant succeeded.  
  13.  
  14. SQL> show parameter recyclebin;  
  15.  
  16. NAME                                 TYPE        VALUE  
  17. ------------------------------------ ----------- ------------------------------  
  18. recyclebin                           string      on 

1.2 use the test user to create two tables, one of which is stored in the system tablespace

 
 
  1. Connected.  
  2. SQL> create table drop_1 (a number) tablespace system;  
  3. Table created.  
  4.  
  5. SQL> insert into drop_1 values (1);  
  6. 1 row created.  
  7.  
  8. SQL> commit;  
  9. Commit complete.  
  10.  
  11. SQL> create table drop_2 as select * from drop_1;  
  12. Table created.  
  13.  
  14. SQL> select * from tab;  
  15.  
  16. TNAME                          TABTYPE  CLUSTERID  
  17. ------------------------------ ------- ----------  
  18. DROP_1                         TABLE 
  19. DROP_2                         TABLE 

1.3 Delete two tables without the purge parameter. Check that the recycle bin only has the drop_2 table. The table's storage tablespace is users, as a result, it is proved that tables stored in the tablespace as system cannot be flashed back and deleted.

 
 
  1. SQL> drop table drop_1;  
  2. Table dropped.  
  3.  
  4. SQL> drop table drop_2;  
  5. Table dropped.  
  6.  
  7. SQL> show recyclebin;  
  8. ORIGINAL NAME    RECYCLEBIN NAME                OBJECT TYPE  DROP TIME 
  9. ---------------- ------------------------------ ------------ -------------------  
  10. DROP_2           BIN$uRD2vL3ZVNjgQKjANQEaNg==$0 TABLE        2012-02-16:16:53:36  
  11.  
  12. SQL> select object_name,original_name from user_recyclebin;  
  13.  
  14. OBJECT_NAME                    ORIGINAL_NAME  
  15. ------------------------------ --------------------------------  
  16. BIN$uRD2vL3ZVNjgQKjANQEaNg==$0 DROP_2  
  17.  
  18. SQL> flashback table drop_2 to before drop;  
  19. Flashback complete. 

1.4 test whether the drop_2 table can be deleted with sys user.

 
 
  1. SQL> conn /as sysdba  
  2. Connected.  
  3. SQL> show user;  
  4. USER is "SYS" 
  5. SQL> drop table test.drop_2;  
  6. Table dropped.  
  7.  
  8. SQL> conn test/123456  
  9. Connected.  
  10. SQL> select * from tab;  
  11.  
  12. TNAME                          TABTYPE  CLUSTERID  
  13. ------------------------------ ------- ----------  
  14. BIN$uRImQA9UYD7gQKjANQEdrg==$0 TABLE 
  15.  
  16. SQL> show recyclebin;  
  17. ORIGINAL NAME    RECYCLEBIN NAME                OBJECT TYPE  DROP TIME 
  18. ---------------- ------------------------------ ------------ -------------------  
  19. DROP_2           BIN$uRImQA9UYD7gQKjANQEdrg==$0 TABLE        2012-02-16:17:06:54  
  20.  
  21. SQL> flashback table drop_2 to before drop;  
  22. Flashback complete 
  • 1
  • 2
  • 3
  • Next Page

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.