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