views:

587

answers:

4

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

+2  A: 

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

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

APC
+2  A: 

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.

Pavel Mitrofanov
A: 

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).
FerranB
A: 

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;

geekzspot