Name of the function
OptionalschemaSchema where the function belongs
OptionalparamsInput parameters
The function body (SQL statements / expression)
Return type. Required: unlike procedures, functions always return a value.
OptionallanguageLanguage (SQL, plpgsql, etc.). Defaults to 'SQL'.
OptionalvolatilityVolatility/optimization category:
VOLATILE (default if omitted): may modify the database and/or return
different results on successive calls with the same arguments.STABLE: cannot modify the database, and is guaranteed to return the
same results given the same arguments within a single statement.IMMUTABLE: cannot modify the database and always returns the same
results given the same arguments. Required for use in computed columns.OptionalreplaceIf true, uses CREATE OR REPLACE
OptionalifIf true, does not throw if already exists
OptionalcommentOptional comment
Options for creating a user-defined function (UDF).
Deliberately shaped to mirror
StoredProcedureOptionsas closely as possible, sinceCREATE FUNCTIONandCREATE PROCEDUREshare almost identical grammar in Postgres-family dialects (CockroachDB, Postgres). The main differences are that a function always has areturnTypeand may declare avolatilitycategory, which procedures do not have.