ScArcher2
ScArcher2

Reputation: 87177

How do I delete a stored procedure in Postgresql?

How do I delete a stored procedure in Postgresql?

Upvotes: 20

Views: 18736

Answers (4)

Ady
Ady

Reputation: 702

I was able to drop a Stored Procedure by below command:

DROP PROCEDURE IF EXISTS <schema-name>.<procedure-name>(all-arguments);

Example:

DROP PROCEDURE IF EXISTS public.my_procedure(empname character varying);

Upvotes: 7

Lukasz Szozda
Lukasz Szozda

Reputation: 175586

PostgreSQL 11 introduced stored procedures. Plus it adds new syntax DROP ROUTINE:

DROP ROUTINE [ IF EXISTS ] name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ] [, ...]

DROP ROUTINE removes the definition of an existing routine, which can be an aggregate function, a normal function, or a procedure.

DROP ROUTINE IF EXISTS foo(integer);

This command conforms to the SQL standard, with these PostgreSQL extensions:

  • The standard only allows one routine to be dropped per command.

  • The IF EXISTS option

  • The ability to specify argument modes and names

  • Aggregate functions are an extension.

Upvotes: 2

panser
panser

Reputation: 2129

you can delete it even without arguments name

DROP FUNCTION IF EXISTS name;

Upvotes: 3

user80168
user80168

Reputation:

DROP FUNCTION name(arguments);

Upvotes: 25

Related Questions