如何在Postgresql中删除存储过程?

18

我该如何在Postgresql中删除存储过程?

4个回答

23
DROP FUNCTION name(arguments);

我不知道我需要指定参数,但这很有道理。 - ScArcher2

5

我可以通过以下命令删除存储过程(Stored Procedure)

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

示例:

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

3

即使没有参数名称,您也可以将其删除。

DROP FUNCTION IF EXISTS name;

可以使用相同名称但不同参数集的过程,因此最好在调用时提供参数以更精确地执行。 - Ady

1

PostgreSQL 11引入了存储过程。此外,它还添加了新的语法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.


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接