Skip to main content
Documents
Clauses StatementsKeywordsExpressionsFunctionsIndexesPerformance Optimization

MySQL SHOW FUNCTION STATUS Statements

The `SHOW FUNCTION STATUS` statement in MySQL provides information about stored functions, including their names, creation dates, and character sets. It is useful for database administrators and developers who need to manage and review the functions within a database.

Usage

The `SHOW FUNCTION STATUS` statement is used to display metadata about stored functions in a MySQL database. It is particularly helpful for auditing and troubleshooting stored functions.

SHOW FUNCTION STATUS
[LIKE 'pattern' | WHERE expression];

In this syntax, the optional `LIKE` or `WHERE` clause can be used to filter the results based on a specific pattern or condition. The `LIKE` clause supports the use of wildcard characters like `%` to match zero or more characters.

Examples

1. Display All Functions

SHOW FUNCTION STATUS;

This example retrieves a list of all stored functions across all databases, showing details like function names and creation times.

2. Filter Functions by Name

SHOW FUNCTION STATUS LIKE 'calculate%';

This syntax filters and displays functions whose names start with 'calculate', helping to quickly find and review specific functions.

3. Filter Functions by Database

SHOW FUNCTION STATUS WHERE Db = 'sales';

In this example, the statement filters functions by the `sales` database, allowing users to manage functions within a specific database context.

Output Fields

The `SHOW FUNCTION STATUS` statement returns several fields, including:

  • Db: The database where the function resides.
  • Name: The name of the function.
  • Type: The object type, which is always `FUNCTION`.
  • Definer: The account that created the function.
  • Modified: The timestamp of the last modification.
  • Created: The timestamp of function creation.
  • Security_type: The security context under which the function executes.
  • Comment: Any comment provided about the function.
  • character_set_client: The character set of the client.
  • collation_connection: The collation of the connection.
  • Database Collation: The collation of the database.

Tips and Best Practices

  • Use filters for clarity. Apply `LIKE` or `WHERE` clauses to narrow down results to relevant functions, improving readability and efficiency.
  • Regularly audit functions. Periodically use `SHOW FUNCTION STATUS` to keep track of function changes and ensure they meet development and security standards.
  • Combine with other information. Use alongside other `SHOW` statements (e.g., `SHOW PROCEDURE STATUS`) for comprehensive database management.
  • Check permissions. Ensure you have sufficient privileges to execute `SHOW FUNCTION STATUS` and view associated metadata. Typically, you need the `SELECT` privilege on the `mysql` database.
  • Performance considerations. Be mindful when using `SHOW FUNCTION STATUS` on databases with a large number of functions, as this can impact performance. Consider filtering results to mitigate this issue.

SQL Upskilling for Beginners

Gain the SQL skills to interact with and query your data.
Start Learning for Free