drop table and purge usages in Oracle database

Source: Internet
Author: User

drop table and purge   in oracle  database actual example:  create OR REPLACE PROCEDURE pro_droptable is   Cursor cur is     SELECT table_name from user_tables where table_name like ' temptable% ';   drop_s QL     VARCHAR2 (;   table_number number; begin   SELECT COUNT (*) into Table_ Number from User_tables WHERE table_name like ' tem% ';   for tbname in cur loop     BEGIN&NBSP;&NB Sp     If Table_number < then         exit;       End if; & nbsp     Drop_sql: = ' drop table ' | | Tbname.table_name | | ' Purge ';       Execute immediate drop_sql;       table_number: = table_number-1;          end;   end loop; end pro_droptable;  explanation:  The drop table is placed in the Recycle Bin (user_recyclebin) instead of being deleted directly. In this way, the table information in the Recycle Bin can be restored or completely erased.  1. Getting deleted table information by querying the Recycle Bin User_recyclebin, and then use the statement  flashback table <user_recyclebin.object_name or user_recyclebin.original_name> to before drop [ Rename to <new_table_name>];  restores the table in the Recycle Bin to its original name or specifies a new name, and the data in the table is not lost.   To completely delete a table, use the statement: Drop table <table_name> purge; 2. Clears the information in the Recycle Bin   clears the specified tables: Purge table <table_name> ;  clearing the Recycle Bin for the current user: Purge recyclebin;  clearing the Recycle Bin for all users: Purge dba_recyclebin;  example 2: create OR REPLACE PROCEDURE pro_clean_recycle Is --tmpvar number; clean_recycle_sql varchar2 (+); begin    --purge recyclebin;    clean_recycle_sql: = ' purge RecycleBin ';    execute Immediate Clean_recycle_sql; end pro_clean_recycle;

Drop table and purge usages in Oracle database

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.