ORACLE recycle bin sorting

Source: Internet
Author: User

ORACLE recycle bin sorting
In principle, the Recycle Bin is a data dictionary table that stores information about database objects deleted by users. Objects deleted by a user are not deleted by the database and still occupy space. Unless the user Purge manually or the database is cleared because the storage space is insufficient. Www.2cto.com introduces a Recycle Bin database object in the Oracle 10g Database. The recycle bin, as its name implies, stores deleted items. In principle, it is a data dictionary table that stores information about database objects deleted by users. Objects deleted by a user are not deleted by the database and still occupy space. Unless the user Purge manually or the database is cleared because the storage space is insufficient. The database has such a function, which can reduce a lot of unnecessary troubles. If a table is deleted, objects associated with the table, such as indexes, constraints, and other dependent objects, are prefixed with bin $. You can use the following query statement to view the current status of the recycle bin: SELECT Value from v $ parameter WHERE Name = 'recyclebin '; if the returned value is "on", it indicates that the recycle bin is started, and "off" indicates that it is disabled. Of course, you can start or stop each session and system in the recycle bin. The Code is as follows: alter system set recyclebin = ON; alter session set recyclebin = ON; alter system set recyclebin = OFF; alter session set recyclebin = OFF; you can use any of the following statements to retrieve the content in the recycle bin: SELECT * from recyclebin; SELECT * FROM USER_RECYCLEBIN; SELECT * FROM DBA_RECYCLEBIN; you can use the following syntax TO restore the deleted object: 1 flashback table <Dropped_Table_Name> to before drop rename to <New_T Able_Name >>; note: the RENAME here is an optional command to RENAME the deleted object. Clearing the recycle bin contains two conditions: first, you can clear the recycle bin with conditions, and second, clear all. Let's first look at how to do conditional clearing:. clear a specific TABLE: purge table <Table_NAME>; B. clear a specific INDEX: purge index <Index_NAME>; c. clear the objects associated with the TABLESPACE: purge tablespace <Table_NAME>; d. clear the TABLESPACE objects of a specific USER: purge tablespace <Table_NAME> USER <User_Name>; e. clear the recycle bin: purge recyclebin; f. when a TABLE is deleted (drop), the drop table <Table_Name> PURGE; Demo1. enable the recycle bin function alter system set recyclebin = ON; 2. create table DEMO_RECYCLEBIN (COL1 NUMBER); 3. INSERT a data insert into DEMO_RECYCLEBIN (COL1) VALUES (1); COMMIT; 4. delete (Drop) DEMO_RECYCLEBIN table drop table DEMO_RECYCLEBIN; 5. query SELECT * FROM USER_RECYCLEBIN; Result: 6. restore the DEMO_RECYCLEBIN table flashback table DEMO_RECYCLEBIN to before drop from the recycle bin; 7. query SELECT * FROM DEMO_RECYCLEBIN after restoration; the query results are consistent with those before deletion. 8. Delete the TABLE and clear it from the recycle bin drop table DEMO_RECYCLEBIN PURGE;

Related Article

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.