CREATE/REPLACE FUNCTION SQL Statement | Teradata Database - CREATE FUNCTION and REPLACE FUNCTION (SQL Form) - Teradata Database

SQL Data Definition Language Syntax and Examples

Deployment
VantageCloud
VantageCore
Edition
VMware
Enterprise
IntelliFlex
Product
Teradata Database
Release Number
20.00
Publication Date
June 2025
Content Type
SQL Reference
Publication ID
B035-1144-200K
ft:locale
en-US
ft:lastEdition
2026-09-23
dita:mapPath
mbm1747160743883.ditamap
dita:ditavalPath
jlp1749501702948.ditaval
ft:sourceId
dita
dita:id
mdr1472255012272
lifecycle
latest

Creates or replaces an SQL UDF.

ANSI Compliance

CREATE FUNCTION (SQL Form):

This statement is a Teradata extension to the ANSI SQL:2011 standard.

REPLACE FUNCTION (SQL Form):

This statement is a Teradata extension to the ANSI SQL:2011 standard.

Required Privileges

The privileges required to perform CREATE FUNCTION and REPLACE FUNCTION (SQL Form) differ as follows:
  • You must have explicit CREATE FUNCTION privileges on the database, including SYSUDTLIB for SQL UDFs associated with UDTs, in which the function is to be contained to perform the CREATE FUNCTION request.

    The system does not grant the CREATE FUNCTION privilege automatically when you create a database or user: you must grant the privilege explicitly.

    CREATE FUNCTION is not granted implicitly on the databases and functions owned by a database or user unless the owner also has an explicit WITH GRANT OPTION privilege defined for itself.

  • You must have explicit DROP FUNCTION privileges on the function or on the database in which the function is contained to perform the REPLACE FUNCTION (SQL Form) statement on an existing function. You do not need the CREATE FUNCTION privilege to replace a function.
  • You must have explicit CREATE FUNCTION privileges on the database in which the function is to be contained to perform the REPLACE FUNCTION (SQL Form) statement to create a new function.
If a UDT is specified as an input parameter or the SQL function result, the current user must have one of the following privileges:
  • UDTUSAGE on the SYSUDTLIB database.
  • UDTUSAGE on the specified UDT.

Privileges Granted Automatically

The following privileges are granted automatically to the creator of an SQL function:
  • DROP FUNCTION
  • EXECUTE FUNCTION