PostgreSQL · Command
CREATE FUNCTION
CREATE FUNCTION defines a PostgreSQL function. It specifies the function's inputs, result, implementation language, body, and optional behavior such as null handling and security.
Last updated
Syntax
CREATE [ OR REPLACE ] FUNCTION name ( [ [ argmode ] [ argname ] argtype [ { DEFAULT | = } default_expr ] [, ...] ] ) [ RETURNS rettype | RETURNS TABLE ( column_name column_type [, ...] ) ] { LANGUAGE lang_name | TRANSFORM { FOR TYPE type_name } [, ...] | WINDOW | { IMMUTABLE | STABLE | VOLATILE } | [ NOT ] LEAKPROOF | { CALLED ON NULL INPUT | RETURNS NULL ON NULL INPUT | STRICT } | { [ EXTERNAL ] SECURITY INVOKER | [ EXTERNAL ] SECURITY DEFINER } | PARALLEL { UNSAFE | RESTRICTED | SAFE } | COST execution_cost | ROWS result_rows | SUPPORT support_function | SET configuration_parameter { TO value | = value | FROM CURRENT } | AS ' definition ' | AS ' obj_file ', ' link_symbol ' | sql_body } ...In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
ALTER FUNCTIONDROP FUNCTIONGRANTLOADREVOKE