CREATE FUNCTION
Create a new function.
Table of contents
Synopsis
CREATE [OR REPLACE] FUNCTION function_name
( [ [arg_name] arg_type ] [, ...] ] )
RETURNS return_type
LANGUAGE language_name
AS 'definition'
Description
CREATE FUNCTION
creates a new user-defined function.
CREATE OR REPLACE FUNCTION
will either create a new function, or replace an existing function.
The signature of the function is defined by its schema, name, and input arguments.
You can overload functions by defining two functions of the same name, but with a different set of input arguments.
Parameters
function_name
The name of the function to create.
arg_name
The optional name given to an argument. Function arguments do not retain names, but you can name them in your query for documentation purposes.
arg_type
The data type of a given argument.
return_type
The returned data type of the function. The return type can be any supported type.
language_name
The registered language which should be used for the function.
definition
A string defining the body of the function.