Documentation Home
MySQL 5.7 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 39.4Mb
PDF (A4) - 39.4Mb
PDF (RPM) - 38.7Mb
HTML Download (TGZ) - 11.1Mb
HTML Download (Zip) - 11.1Mb
HTML Download (RPM) - 9.8Mb
Man Pages (TGZ) - 213.4Kb
Man Pages (Zip) - 322.6Kb
Info (Gzip) - 3.6Mb
Info (Zip) - 3.6Mb
Excerpts from this Manual

MySQL 5.7 Reference Manual  /  ...  /  Installing and Uninstalling User-Defined Functions

5.6.1 Installing and Uninstalling User-Defined Functions

User-defined functions (UDFs) must be loaded into the server before they can be used. MySQL supports UDF loading at runtime.

To load a UDF, use the CREATE FUNCTION statement. For example:

  SONAME '';

The UDF file base name depends on your platform. Common suffixes are .so for Unix and Unix-like systems, .dll for Windows.

While a UDF is loaded, information about it is available from the mysql.func system table. See Section 5.6.2, “Obtaining User-Defined Function Information”.

The statement also registers the UDF in the mysql.func system table to cause the server to load it on subsequent restarts. For this reason, CREATE FUNCTION requires the INSERT privilege for the mysql database.

To remove a UDF, use the DROP FUNCTION statement. For example:


CREATE FUNCTION unloads the UDF and removes it from the mysql.func system table. For this reason, DROP FUNCTION statement requires the DELETE privilege for the mysql database. With the UDF no longer registered in the table, the server does not load the UDF automatically for subsequent restarts.

You cannnot use CREATE FUNCTION to reinstall a function that has previously been installed. To reinstall a function, first remove it with DROP FUNCTION, then install it again with CREATE FUNCTION. You would need to do this, for example, if you upgrade to a new version of MySQL that provides an updated implementation of the function, or you recompile a new version of a function that you have written. Otherwise, the server continues to use the old version.

If the server is started with the --skip-grant-tables option, it does not consult the mysql.func table and does not load the UDFs listed there.

User Comments
User comments in this section are, as the name implies, provided by MySQL users. The MySQL documentation team is not responsible for, nor do they endorse, any of the information provided here.
Sign Up Login You must be logged in to post a comment.