CREATE [AGGREGATE] FUNCTION function_nameRETURNS {STRING|REAL|INTEGER} SONAME shared_library_name

Description: Creates a new user-defined function (UDF) that may be called as function_name() in the same way as MySQL's built-in functions.

The AGGREGATE option (new in version 3.23) specifies that the function will be an aggregating function (such as COUNT()).

Functions must be written in C or C++. shared_library_name is the name of the compiled .so file, residing in a directory searched by ld.

Limitations: Requires user to have insert privileges for the mysql database. MySQL must have been compiled dynamically, and the operating system must support dynamic loading.

Description in: Day 21

See also: DROP FUNCTION

Get Sams Teach Yourself MySQL in 21 Days, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.