Documentation Home
MySQL 8.4 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 39.8Mb
PDF (A4) - 39.9Mb
Man Pages (TGZ) - 257.9Kb
Man Pages (Zip) - 364.9Kb
Info (Gzip) - 4.0Mb
Info (Zip) - 4.0Mb


MySQL 8.4 Reference Manual  /  ...  /  SHOW CREATE PROCEDURE Statement

15.7.7.10 显示创建存储过程语句

SHOW CREATE PROCEDURE proc_name

这是MySQL的扩展语句。它返回用于重新创建命名存储过程的exact字符串。类似语句SHOW CREATE FUNCTION显示关于存储函数的信息(见第15.7.7.9节,“SHOW CREATE FUNCTION Statement”).

要使用任何语句,您必须是命名存储过程的用户DEFINER,拥有SHOW_ROUTINE权限,拥有SELECT权限在全局级别,或者拥有CREATE ROUTINEALTER ROUTINEEXECUTE权限在包含存储过程的范围内。显示的Create ProcedureCreate Function字段的值为NULL如果您只有CREATE ROUTINEALTER ROUTINEEXECUTE权限。

mysql> SHOW CREATE PROCEDURE test.citycount\G
*************************** 1. row ***************************
           Procedure: citycount
            sql_mode: ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,
                      NO_ZERO_IN_DATE,NO_ZERO_DATE,
                      ERROR_FOR_DIVISION_BY_ZERO,
                      NO_ENGINE_SUBSTITUTION
    Create Procedure: CREATE DEFINER=`me`@`localhost`
                      PROCEDURE `citycount`(IN country CHAR(3), OUT cities INT)
                      BEGIN
                        SELECT COUNT(*) INTO cities FROM world.city
                        WHERE CountryCode = country;
                      END
character_set_client: utf8mb4
collation_connection: utf8mb4_0900_ai_ci
  Database Collation: utf8mb4_0900_ai_ci

mysql> SHOW CREATE FUNCTION test.hello\G
*************************** 1. row ***************************
            Function: hello
            sql_mode: ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,
                      NO_ZERO_IN_DATE,NO_ZERO_DATE,
                      ERROR_FOR_DIVISION_BY_ZERO,
                      NO_ENGINE_SUBSTITUTION
     Create Function: CREATE DEFINER=`me`@`localhost`
                      FUNCTION `hello`(s CHAR(20))
                      RETURNS char(50) CHARSET utf8mb4
                      DETERMINISTIC
                      RETURN CONCAT('Hello, ',s,'!')
character_set_client: utf8mb4
collation_connection: utf8mb4_0900_ai_ci
  Database Collation: utf8mb4_0900_ai_ci

character_set_client是存储过程创建时的character_set_client系统变量的会话值。collation_connection是存储过程创建时的collation_connection系统变量的会话值。Database Collation是与存储过程关联的数据库的排序规则。