如何重命名 Oracle 过程

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2221202/
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-10 02:23:02  来源:igfitidea点击:

How to rename an Oracle procedure

oraclestored-procedures

提问by ash

Is there a way to rename an oracle procedure, without having to drop and recreate the procedure?

有没有办法重命名 oracle 过程,而不必删除并重新创建该过程?

回答by APC

UNfortunately there is no equivalent of ALTER TABLE ... RENAMETO for PL/SQL objects. So I'm afraid you will have to drop the procedure and create it afresh with the new name....

不幸的是ALTER TABLE ... RENAME,PL/SQL 对象没有TO 的等价物。因此,恐怕您将不得不放弃该程序并使用新名称重新创建它....

... unless using a SYNONYM will resolve your bind. Without knowing whyyou want to change the procedure name it's a bit difficult to give advice.

...除非使用同义词将解决您的绑定。在不知道为什么要更改程序名称的情况下,给出建议有点困难。

回答by Pavel Mitrofanov

A way around this would be using a procedure inside a package. Then you might use CREATE OR REPLACE PACKAGE ...and CREATE OR REPLACE PACKAGE BODY ...to achieve your goal.

解决此问题的一种方法是使用包内的过程。然后你可以使用CREATE OR REPLACE PACKAGE ...CREATE OR REPLACE PACKAGE BODY ...来实现你的目标。

回答by FerranB

There is no way to rename a procedure unless you drop and create it again. Anyway:

除非您删除并再次创建它,否则无法重命名过程。反正:

  • If you have a lot of procedures you'd have to use PACKAGEs instead of PROCEDUREs. In this way you'd only need to change the PACKAGE BODY.
  • If your problem is to recreate the grants you can create easily an script to do it querying DBA_TAB_PRIVS(yes, also contains privileges for procedures).
  • 如果您有很多过程,则必须使用PACKAGEs 而不是PROCEDUREs。通过这种方式,您只需要更改PACKAGE BODY.
  • 如果您的问题是重新创建授权,您可以轻松创建一个脚本来进行查询DBA_TAB_PRIVS(是的,还包含过程权限)。

回答by geekzspot

You can effectively rename a Procedure by simply creating another procedure - with the new name - that simply calls the old procedure

您可以通过简单地创建另一个过程(使用新名称)来有效地重命名过程,该过程仅调用旧过程

create or replace procedure new_procedure_name
as
begin

old_procedure_name;

end;

创建或替换过程new_procedure_name
作为
开始

old_procedure_name;

结尾;