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_USER | SESSION_USER }
    ALTER ROUTINE name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]
        SET SCHEMA new_schema
    ALTER ROUTINE name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]
        DEPENDS ON EXTENSION extension_name

    其中action是下列之一:

        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

示例

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

    ALTER ROUTINE foo(integer) RENAME TO foobar;

不管foo是聚集、函数还是过程,这个命令都能使用。