Welcome 微信登录

首页 / 数据库 / MySQL / Oracle 数据库中 drop table 与purge

实际示例:CREATE OR REPLACE PROCEDURE pro_droptable IS  cursor cur is    select table_name from user_tables where table_name like "TEMPTABLE%";  drop_sql     varchar2(1000);  table_number number;BEGIN  SELECT COUNT(*) INTO table_number from USER_TABLES WHERE TABLE_NAME LIKE "TEM%";  for tbname in cur loop    begin      if table_number < 50 then        exit;      end if;      drop_sql := "drop table " || tbname.table_name || "purge";      execute immediate drop_sql;      table_number := table_number - 1;       end;  end loop;END pro_droptable;解释:drop后的表被放在回收站(user_recyclebin)里,而不是直接删除掉。这样,回收站里的表信息就可以被恢复,或彻底清除。
1.通过查询回收站user_recyclebin获取被删除的表信息,然后使用语句
flashback table <user_recyclebin.object_name or user_recyclebin.original_name> to before drop [rename to <new_table_name>];
将回收站里的表恢复为原名称或指定新名称,表中数据不会丢失。
若要彻底删除表,则使用语句:drop table <table_name> purge;
2.清除回收站里的信息
清除指定表:purge table <table_name>;
清除当前用户的回收站:purge recyclebin;
清除所有用户的回收站:purge dba_recyclebin;
示例2:CREATE OR REPLACE PROCEDURE pro_clean_recycle IS--tmpVar NUMBER;clean_recycle_sql varchar2(1000);BEGIN   --purge recyclebin;   clean_recycle_sql :="purge recyclebin";   execute immediate clean_recycle_sql;END pro_clean_recycle;更多Oracle相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12Oracle中光标的使用和异常详解 MySQL Replication Error 1032 & 1052相关资讯      Oracle数据库 
  • Oracle数据库全球化  (03月01日)
  • Oracle数据库日期过滤方法性能比较  (02/02/2015 13:20:26)
  • Oracle数据库安装中端口被占用问题  (10/29/2014 07:42:24)
  • 在CentOS 6.6上搭建C++运行环境并  (10/10/2015 19:44:40)
  • Oracle数据库无法使用localhost和  (11/14/2014 16:39:10)
  • Oracle 多数据库的数据同时更新  (06/16/2014 21:52:23)
本文评论 查看全部评论 (0)
表情: 姓名: 字数