📜  select * from mysql.proc - SQL (1)

📅  最后修改于: 2023-12-03 14:47:21.665000             🧑  作者: Mango

Introduction to 'select * from mysql.proc - SQL'

In SQL, the statement 'select * from mysql.proc' retrieves information about stored procedures and functions stored in the 'mysql.proc' system table. This table contains details about the procedural objects defined in the MySQL server.

Syntax

The syntax for the 'select * from mysql.proc' statement is as follows:

SELECT * FROM mysql.proc;
Explanation

When the above query is executed, it fetches all the rows from the 'mysql.proc' table. Each row represents a stored procedure or function defined in the MySQL server.

The 'mysql.proc' table contains several columns including:

  • db: The database name where the procedural object is defined.
  • name: The name of the procedural object.
  • type: The type of the procedural object, which can be 'PROCEDURE' or 'FUNCTION'.
  • specific_name: The specific name of the procedural object, which is unique within the database.
  • language: The programming language used for the procedural object (e.g., SQL, JavaScript, etc.).
  • sql_data_access: The data access type required for the procedural object.
  • is_deterministic: Indicates if the procedural object is deterministic (returns the same result for the same input).
  • security_type: The security type associated with the procedural object.
  • created: The timestamp indicating when the procedural object was created.
  • modified: The timestamp indicating when the procedural object was last modified.
  • sql_mode: The SQL mode under which the procedural object was created.

This information can be helpful for programmers to understand the existing procedures and functions in the MySQL server and analyze their structure, dependencies, and other attributes.

Example

Here's an example result of executing the 'select * from mysql.proc' statement:

| db | name | type | specific_name | language | sql_data_access | is_deterministic | security_type | created | modified | sql_mode | |----------|---------|-----------|----------------|----------|-----------------|------------------|---------------|---------------------|---------------------|---------------------------------------------------| | mydb | my_proc | PROCEDURE | my_proc_12345 | SQL | CONTAINS_SQL | NO | DEFINER | 2022-01-01 10:00:00 | 2022-01-02 14:30:00 | STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO | | mydb | my_func | FUNCTION | my_func_67890 | SQL | NO_SQL | YES | INVOKER | 2022-01-01 12:00:00 | 2022-01-02 15:00:00 | STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE |

This result set shows two procedural objects: a stored procedure named 'my_proc' and a stored function named 'my_func'. It includes various details such as their names, types, specific names, languages, data access types, determinism, security types, creation/modification timestamps, and SQL mode used during creation.

Please note that the actual result may vary based on the specific setup and procedural objects defined in your MySQL server.

Note: The 'mysql.proc' table is internal to the MySQL server, and direct modifications to it are not recommended. It is generally safer to use appropriate SQL statements (e.g., 'CREATE PROCEDURE', 'CREATE FUNCTION') to create and manage stored procedures and functions.