IT运维笔记


恢复oracle中误删除drop掉的表

1、查询表创建时间

SELECT OBJECT_NAME, CREATED
FROM ALL_OBJECTS
WHERE OBJECT_TYPE = 'TABLE'
 and object_name ='temp1'
ORDER BY CREATED DESC;

2、假如误操作

drop table temp1; commit;

3、查看回收站中表

select object_name,original_name,partition_name,type,ts_name,createtime,droptime from recyclebin;
object_name  original_name
BIN$abcd$0             IND_TEMP1
BIN$hgcd$0             TEMP1

4、恢复表

flashback table test_drop to before drop;
flashback table "BIN$hgcd$0   " to before drop;

5、恢复索引

select INDEX_NAME from user_indexs where table_name='TEMP1'
INDEX_NAME BIN$abcd$0 虽然看起来表已经恢复了,但是索引恢复的有点问题,恢复出来的索引名称不是IND_TEMP1,故我们还要手动完成索引名修改。
alter index "BIN$abcd$0" rename to IND_TEMP1;

6、清空回收站

purge recyclebin;