CREATE/REPLACE FUNCTION SQL Statement | VantageCloud Lake - CREATE FUNCTION and REPLACE FUNCTION (External Form) - Teradata VantageCloud Lake

Lake - Working with SQL

Deployment
VantageCloud
Edition
Lake
Product
Teradata VantageCloud Lake
Release Number
Published
February 2025
ft:locale
en-US
ft:lastEdition
2025-11-21
dita:mapPath
jbe1714339405530.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
jbe1714339405530

Compiles and installs an external UDF and creates or replaces the SQL function definition used to invoke that UDF.

You cannot use CREATE/REPLACE FUNCTION or CREATE/REPLACE PROCEDURE to create user-defined functions or external stored procedures in C/C++ or Java in VantageCloud Lake. To create, migrate, and manage user-defined functions or external stored procedures, you must use the External Routine Installation Tool (tdextroutine) to create and manage them. See Create, Use, and Migrate UDFs and External Stored Procedures in VantageCloud Lake

ANSI Compliance

CREATE FUNCTION is ANSI SQL:2011-compliant with extensions.

REPLACE FUNCTION is a Teradata extension to the ANSI SQL:2011 standard.

Required Privileges

The privileges required to perform CREATE FUNCTION and REPLACE FUNCTION differ:
  • 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 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 statement to create a new function.
  • If you are not the creator of a function, you must have the EXECUTE FUNCTION privilege on any UDF that you run from the SYSLIB database.

    The creator of a function is granted EXECUTE FUNCTION on that UDF automatically.

If the function is to be used to enforce the security policy for a table row, but the purpose of the function is not to delete, insert, select, or update table rows, you must have the appropriate OVERRIDE DELETE CONSTRAINT, OVERRIDE INSERT CONSTRAINT, OVERRIDE SELECT CONSTRAINT, or OVERRIDE UPDATE CONSTRAINT privilege to run it. The request that invokes the function must also include the values to be assigned to the constraint columns of the target table rows.

Privileges Granted Automatically

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