Is there a way to rename an oracle procedure, without having to drop and recreate the procedure?
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.
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.
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
PACKAGE
s instead ofPROCEDURE
s. In this way you'd only need to change thePACKAGE 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).
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
beginold_procedure_name;
end;