Understanding MySQL CREATE function/drop FUNCTION syntax

Source: Internet
Author: User
Tags mysql create valid mysql database

A custom Function (UDF) extends MySQL by using a new function like an intrinsic (built-in) function like ABS () or CONCAT ().

CREATE [AGGREGATE] FUNCTION function_name RETURNS {STRING|INTEGER|REAL}
    SONAME shared_library_name
DROP FUNCTION function_name

Function_name is the name of the function used in the SQL declaration for invocation. The RETURNS clause describes the type of the function return value. Shared_library_name is the basic name of the shared target file, and the shared target file contains code to implement the function. The file must be located in a directory that can be searched by your system's dynamic connectors.

You must have a MySQL database insert permission to create a function, you must have the MySQL database delete permission to undo a function. This is because the CREATE function adds a row to the MYSQL.FUNC system table that records the function name, type, and share name, and the drop function deletes the row from the list. If you do not have this system table, you should run the Mysql_fix_privilege_tables script to create one.

A valid function is one that is loaded with the CREATE function and is not removed with the drop function. All valid functions are reloaded every time the server starts, unless you use the--skip-grant-tables parameter to start the mysqld. In this case, the initialization of the UDF is skipped and the UDF is not available.

To enable the UDF mechanism to work, you must write functions in C or C + +, your system must support dynamic loading, and you must be dynamically compiled Mysqld (non-static).

A aggregate function works like a MySQL intrinsic set (sum) function, such as the sum or count () function. To make aggregate work, your Mysql.func table must include a type column. If your Mysql.func table does not have this column, you should run the Mysql_fix_privilege_tables script to create this column.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.