功能: 用于备份当前用户所拥有的任何pl/sql objects (包括 type,type body, procedure , function, package, package body or java source ) 原理: 对user_source数据字典的调用,得到任何的 pl/sql 代码. 使用方法举例: 1. 在c盘建立目录c:/export 2. 将export_source.sql和extract_source.sql拷贝到c盘根目录. 3. 登陆sqlplus , connect scott/tiger 4. 运行@c:/export_source.sql 5. 执行结束,任何的scott拥有的pl/sql object的代码文档建立在c:/export目录里. 后缀名.pks 表示package 后缀名.pkb 表示package body 后缀名.sql 表示其他objects 备注: 假如想得到数据库中各个schema的pl/sql objects ,只需把工具代码中的user_source改成dba_source,由system 运行即可. 工具代码: export_source.sql set serveroutput on size 1000000 set echo off verify off feedback off trimspool on pages 0 lines 512 set termout off set termout on prompt prompt pl/sql export utility prompt prompt this utilty exports all of the current schemas pl/sql source code into prompt a subdirectory called export. prompt prompt exporting current users source to folder ./export set termout off spool temp_source_extract.sql prompt set echo off verify off feedback off trimspool on termout off pages 0 lines 512 declare /* || this cursor extracts each pl/sql stored procedures name and procedure type */ cursor cur_source_programs is select distinct us.name, us.type, us.name || decode(us.type, package, .pks, package body, .pkb, .sql) spool_file from user_source us order by us.name, us.type; begin for cur_source_programs_row in cur_source_programs loop dbms_output.put_line(spool export/ || user || _ || cur_source_programs_row.spool_file); dbms_output.put_line(@extract_source || cur_source_programs_row.name || " || cur_source_programs_row.type || "); dbms_output.put_line(spool off); end loop; end; / spool off @temp_source_extract set feedback on verify on termout on prompt export complete! prompt extract_source.sql: set head off verify off prompt –************************************************************************************–; prompt –*; prompt –* script: &2 &1; prompt –*; prompt –* author:; prompt –*; prompt –*; prompt –* purpose:; prompt –*; prompt –*; prompt –*; prompt –*; prompt –*; prompt –* parameters:; prompt –*; prompt –*; prompt –* dependencies: none; prompt –*; prompt –* revisions:; prompt –* ver date author description; prompt –* ——— ———- —————— ————————————; prompt –* ; prompt –*; prompt –*************************************************************************************–; select decode(rownum, 1, create or replace || rtrim(rtrim(us.text, chr(10) )), rtrim(rtrim(us.text, chr(10) ))) text from user_source us where us.name = &1 and us.type = &2 order by us.line; prompt / prompt
以上内容由 华夏名网 收集整理,如转载请注明原文出处,并保留这一部分内容。
“华夏名网” http://www.sudu.cn 和 http://www.bigwww.com 是成都飞数科技有限公司的网络服务品牌,专业经营虚拟主机,域名注册,VPS,服务器租赁业务。公司创建于2002年,经过近5年的高速发展,“华夏名 网”已经成为我国一家知名的互联网服务提供商,被国外权威机构webhosting.info评价为25大IDC服务商之一。
原创文章,作者:优速盾-小U,如若转载,请注明出处:https://www.cdnb.net/bbs/archives/31659