第二章 SQL命令参考-ALTER FUNCTION

来源:互联网 发布:外企 工作 知乎 编辑:程序博客网 时间:2024/05/12 15:34


ALTER FUNCTION

更改函数的定义。

概要

ALTERFUNCTION name ( [ [argmode] [argname] argtype [,...] ] )

action [, ... ] [RESTRICT]

ALTERFUNCTION name ( [ [argmode] [argname] argtype [,...] ] )

RENAMETO new_name

ALTERFUNCTION name ( [ [argmode] [argname] argtype [,...] ] )

OWNERTO new_owner

ALTERFUNCTION name ( [ [argmode] [argname] argtype [,...] ] )

SETSCHEMA new_schema

 

where actionis one of:

 

{CALLEDON NULL INPUT | RETURNS NULL ON NULL INPUT | STRICT}

{IMMUTABLE| STABLE | VOLATILE}

{[EXTERNAL]SECURITY INVOKER | [EXTERNAL] SECURITY DEFINER}

 

描述

ALTER FUNCTION更改函数的定义。

你必须拥有这个函数才能去更改函数的定义。要更改函数的模式,您还必须对新模式具有CREATE权限。要更改所有者,您还必须是新拥有角色的直接或间接成员,并且该角色必须对该函数的模式具有CREATE权限。(这些限制强制改变所有者不会通过删除和重新创建功能来做任何事情,但超级用户可以改变任何功能的所有权。)

parameter

name

现有函数的名称(可以带schema前缀)

argmode

INOUTINOUT如果省略,默认值为IN。请注意,ALTERFUNCTION实际上并不关注OUT参数,因为只需要输入参数来确定函数的身份。所以列出ININOUT参数就足够了。

argname

参数的名称。请注意,ALTERFUNCTION实际上并不关心参数名称,因为只需要参数数据类型来确定函数的身份。

argtype

函数的参数的数据类型为3(可选模式限定),如果有的话.

new_name

函数的新名称.

new_owner

函数的新的属主。请注意,如果该功能标记为“安全定义器”,它将随后作为新的所有者执行。

new_schema

函数的新的schema.

CALLED ON NULL INPUT RETURNS NULL ON NULLINPUT STRICT

called on nullinputchanges thefunction so that it will be invoked when some or all of its arguments are null.returns null on null input orstrictchanges the function so that it is notinvoked if any of its arguments are null; instead, a null result is assumedautomatically. Seecreate functionfor more information.

IMMUTABLE

STABLE

VOLATILE

Change the volatility of the function tothe specified setting. Seecreate functionfor details.

[EXTERNAL ] SECURITY INVOKER [EXTERNAL ]SECURITY DEFINER

Change whether the function is a securitydefiner or not. The key wordexternalis ignored for SQL conformance. Seecreatefunctionfor moreinformation about this capability.

RESTRICT

Ignored forconformance with the SQL standard.

Notes

Greenplum Database has limitations on theuse of functions defined asstableorvolatile. Seecreate functionfor moreinformation.

示例

To rename thefunctionsqrtfor typeintegertosquare_root:

ALTER FUNCTIONsqrt(integer) RENAME TO square_root;

To change theowner of the functionsqrtfor typeintegertojoe:

ALTER FUNCTIONsqrt(integer) OWNER TO joe;

To change theschema of the functionsqrtfor typeintegertomath:

ALTER FUNCTIONsqrt(integer) SET SCHEMA math;

兼容性

This statement is partially compatiblewith thealter functionstatement in the SQL standard. The standard allows moreproperties of a function to be modified, but does not provide the ability torename a function, make a function a security definer, or change the owner,schema, or volatility of a function. The standard also requires therestrictkey word, which is optional inGreenplum Database.

相关参考

CREATE FUNCTION,DROP FUNCTION

原创粉丝点击