oracle plsql中包的备份

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31992791/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 02:58:56  来源:igfitidea点击:

Backup of package in oracle plsql

sqloracleplsqlpackageplsqldeveloper

提问by sandywho

I am new to pl/sql, I have a pkg_body and I want to make changes to it. But before doing that I want to take backup of the original pkg. So can I create a new pkg with name **_bkp and just copy the code into it.

我是 pl/sql 的新手,我有一个 pkg_body,我想对其进行更改。但在此之前,我想备份原始 pkg。那么我可以创建一个名为 **_bkp 的新 pkg 并将代码复制到其中吗?

I have found the below code when searched on net

我在网上搜索时找到了以下代码

set pagesize 0
set linesize 800
set trimspool on
set heading off
set feedback off
spool filename.pkb
select text from dba_source where name='objectname' and type='PACKAGE BODY';
spool off
exit

But should I do this?Cant I create a new pkg with different name and copy the original code into it hen make the changes?

但是我应该这样做吗?我不能创建一个具有不同名称的新 pkg 并将原始代码复制到其中然后进行更改吗?

Thanks

谢谢

回答by kevinsky

In PL/SQL developer the top menu bar has an item called Tools.

在 PL/SQL developer 中,顶部菜单栏有一个名为 Tools 的项目。

  • left click to select this
  • a dropdown appears select Export user Objects
  • change user to the owner of the package
  • click on the tiny blank square in the upper right corner of the Name column to sort by name
  • left click to select the package header and body
  • at the bottom right click on the folder icon and select a destination and name for your backup
  • click Export
  • close the window
  • to revert open the file in PL/SQL developer as a command window and run
  • 左键点击选择这个
  • 出现下拉菜单选择导出用户对象
  • 将用户更改为包的所有者
  • 单击名称列右上角的小空白方块以按名称排序
  • 左键单击以选择包标题和正文
  • 在右下角单击文件夹图标并选择备份的目的地和名称
  • 单击导出
  • 关上窗户
  • 在 PL/SQL developer 中恢复打开文件作为命令窗口并运行

回答by Matthew McPeak

This is what source code control (e.g., SVN, PVCS, etc) is for.

这就是源代码控制(例如,SVN、PVCS 等)的用途。

But, here's what you can do.

但是,这是您可以做的。

select dbms_metadata.get_ddl('PACKAGE_SPEC', 'your-package-name-here', user) from dual;

Then, edit the CLOB that is returned to change the name. Do the same thing for the package body.

然后,编辑返回的 CLOB 以更改名称。对包体做同样的事情。

select dbms_metadata.get_ddl('PACKAGE_BODY', 'your-package-name-here', user) from dual;

But again, you should be using SVN or something similar. To make a change, edit the DDL file you got from SVN and run it in the database. Don't use SQL*Navigator/TOAD abilities to edit packages directly and "save" them to the database. Unless maybe if you are the only developer on your team.

但同样,您应该使用 SVN 或类似的东西。要进行更改,请编辑您从 SVN 获得的 DDL 文件并在数据库中运行它。不要使用 SQL*Navigator/TOAD 功能直接编辑包并将它们“保存”到数据库中。除非您是团队中唯一的开发人员。