欢迎来到天天文库
浏览记录
ID:34725126
大小:52.32 KB
页数:5页
时间:2019-03-10
《oracle数据库日期时间使用删除恢复等》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、Oracle批量删除表、索引等对象、批量恢复Drop操作删除的表、索引等对象虽然能够恢复表结构和数据,但是索引,主键,约束等,并不能完全恢复。/**********************************************************************查询Drop操作删除的对象select*fromrecyclebin;单个对象(表、索引或是通过drop操作删除的其它对象)恢复flashbacktable(被删除的对象类型)被删除的对象名称tobeforedrop****************
2、*******************************************************/--Demo单张表恢复flashbacktableTable_XXXtobeforedrop;--创建批量恢复表的存储过程createorreplaceprocedureRecoveryOfTableisbegindeclare/***********************************************************************select'flashbacktable'
3、
4、
5、a.original_name
6、
7、'tobeforedrop'fromrecyclebinawherea.operation='DROP'anda.type='TABLE'恢复其它类型对象请将flashbacktable这里换为其它类型,type='相应的类型'可加更多条件限制,具体查询recyclebin***********************************************************************/cursorcur_flashbackisselect'flashbacktab
8、le'
9、
10、a.original_name
11、
12、'tobeforedrop'fromrecyclebinawherea.operation='DROP'anda.type='TABLE';v_namevarchar2(4000);beginopencur_flashback;fetchcur_flashbackintov_name;whilecur_flashback%foundloopexecuteimmediatev_name;fetchcur_flashbackintov_name;endloop;dbms_output.p
13、ut_line('恢复成功!');closecur_flashback;end;end;--执行存储过程(使用plsql操作时)beginRecoveryOfTable;end;--执行存储过程(使用SQL调用)executeRecoveryOfTable;/**************************************批量删除数据库表select*fromuser_tableswheretable_namelike'Table_XXX%';存储过程体*******************************
14、*******/declarecursorcur_deleteisselect'droptable'
15、
16、table_namefromuser_tableswheretable_namelike'Table_XXX%';/*************************************可模板条件删除其它类型对象如:索引等**************************************/v_namevarchar2(4000);beginopencur_delete;fetchcur_deleteintov_
17、name;whilecur_delete%foundloopexecuteimmediatev_name;fetchcur_deleteintov_name;endloop;dbms_output.put_line('将所有Table_XXX开头的表删除!');closecur_delete;end;执行PURGETABLEZYM_USER."BIN$UagqFGZsZcvgQAoKpSB9uQ==$0"--oracletodate函数,to_char函数--oracle24小时selectto_date('2005-01-0
18、113:14:20','yyyy-MM-ddHH24:mi:ss')fromdual;--12小时selectto_date('2005-01-012:14:20','yyyy-MM-ddHH12:mi:ss')fromdual;selectto_char(sysdate,'
此文档下载收益归作者所有