Skip to content

ALTER ROUTINE

ALTER ROUTINE — 更改例程的定义

语法

ALTER ROUTINE name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]
    action [ ... ] [ RESTRICT ]
ALTER ROUTINE name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]
    RENAME TO new_name
ALTER ROUTINE name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]
    OWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
ALTER ROUTINE name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]
    SET SCHEMA new_schema
ALTER ROUTINE name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]
    [ NO ] DEPENDS ON EXTENSION extension_name

where action is one of:

    IMMUTABLE | STABLE | VOLATILE
    [ NOT ] LEAKPROOF
    [ EXTERNAL ] SECURITY INVOKER | [ EXTERNAL ] SECURITY DEFINER
    PARALLEL { UNSAFE | RESTRICTED | SAFE }
    COST execution_cost
    ROWS result_rows
    SET configuration_parameter { TO | = } { value | DEFAULT }
    SET configuration_parameter FROM CURRENT
    RESET configuration_parameter
    RESET ALL

描述

ALTER ROUTINE更改例程的定义,例程可以是聚合函数、普通函数或过程。请参阅ALTER AGGREGATEALTER FUNCTIONALTER PROCEDURE下的内容,了解参数的描述、更多示例和进一步的详细信息。

示例

将类型为integer的例程foo重命名为foobar

ALTER ROUTINE foo(integer) RENAME TO foobar;

无论foo是聚合、函数还是过程,此命令都将起作用。

兼容性

此语句与 SQL 标准中的ALTER ROUTINE语句部分兼容。请参阅ALTER FUNCTIONALTER PROCEDURE下的内容,了解详细信息。允许例程名称引用聚合函数是PostgreSQL的扩展。

另请参见

ALTER AGGREGATEALTER FUNCTIONALTER PROCEDUREDROP ROUTINE请注意,没有CREATE ROUTINE命令。