CREATE/REPLACE FUNCTION Syntax | Teradata Vantage - CREATE FUNCTION and REPLACE FUNCTION Syntax (SQL Form) - Advanced SQL Engine - Teradata Database

SQL Data Definition Language Syntax and Examples

Product
Advanced SQL Engine
Teradata Database
Release Number
17.00
Published
September 2020
Language
English (United States)
Last Update
2021-01-23
dita:mapPath
wgr1555383704548.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1144
lifecycle
previous
Product Category
Teradata Vantage™
{ CREATE | REPLACE } FUNCTION [ database_name_1. | user_name_2. ] function_name
  ( parameter_specification [,...] ) RETURNS return_data_type
  language_and_access_specification
  [ function_attribute [...] ]
  [ SQL SECURITY DEFINER ] COLLATION INVOKER INLINE TYPE 1
  RETURN return_expression [;]
You can specify language_and_access_specification and function_attribute [...] in the reverse order.
parameter_specification
parameter_name parameter_data_type
data_type
{ INTEGER | SMALLINT | BIGINT | BYTEINT | DATE |

  { TIME | TIMESTAMP } [( fractional_seconds_precision)] [WITH TIME ZONE] |

  INTERVAL YEAR [( precision)] [TO MONTH] |

  INTERVAL MONTH [( precision)] |

  INTERVAL DAY [( precision)]
    [TO { HOUR | MINUTE | SECOND [(fractional_seconds_precision)] } ] |

  INTERVAL HOUR [(precision)]
    [TO { MINUTE | SECOND [(fractional_seconds_precision)] } ] |

  INTERVAL MINUTE [(precision)] [ TO SECOND [(fractional_seconds_precision)] ] |

  INTERVAL SECOND [ ( precision [, fractional_seconds_precision ] ) |

  PERIOD (DATE) |

  PERIOD ({ TIME | TIMESTAMP } [(precision)] [ WITH TIME ZONE ]) |

  REAL |

  DOUBLE PRECISION |

  FLOAT [(integer)] |

  NUMBER [({ integer | *} [, integer ]...)] |

  { DECIMAL | NUMERIC } [(integer [, integer ]...)] |

  { CHAR | BYTE | GRAPHIC } [(integer)] |

  { VARCHAR | CHAR VARYING | VARBYTE | VARGRAPHIC } [(integer)] |

  LONG VARCHAR |

  LONG VARGRAPHIC |

  { BINARY LARGE OBJECT | BLOB | CHARACTER LARGE OBJECT | CLOB } (integer [ G | K | M ]) |

  [SYSUDTLIB.] { XML | XMLTYPE } [(integer [ G | K | M ])] [ INLINE LENGTH integer ] |

  [SYSUDTLIB.] JSON [(integer [ K | M ])] [ INLINE LENGTH integer ]
    [ CHARACTER SET { UNICODE | LATIN } ] |

  [SYSUDTLIB.] ST_GEOMETRY [(integer [ K | M ])] [ INLINE LENGTH integer ] |

  [SYSUDTLIB.] DATASET [(integer [ K | M ])] [ INLINE LENGTH integer ]
    storage_format |

  [SYSUDTLIB.] { UDT_name | MBR | ARRAY_name | VARRAY_name }
}
language_and_access_specification
{ [ language_clause] SQL_data_access |
  SQL_data_access [ language_clause ]
}
function_attribute
{ SPECIFIC [ database_name_2. | user_name_2. ] specific_function_name |
  [NOT] DETERMINISTIC |
  CALLED ON NULL INPUT |
  RETURNS NULL ON NULL INPUT  
}
storage_format
STORAGE FORMAT { Avro | CSV [ CHARACTER SET { UNICODE | LATIN } ] }
  [ WITH SCHEMA [ database. ] schema_name ]