Documentation Home

13.7.7.9 显示创建过程语句

SHOW CREATE PROCEDURE proc_name

这个语句是一个 MySQL 扩展。它返回可用于重新创建命名存储过程的确切字符串。类似的语句,SHOW CREATE FUNCTION显示有关存储函数的信息(请参阅第 13.7.7.8 节,“SHOW CREATE FUNCTION 语句”)。

要使用任一语句,您必须是名为 routine 的用户DEFINER,具有 SHOW_ROUTINE特权,具有 SELECT全局级别的特权,或者具有在包含例程的范围内授予的CREATE ROUTINEALTER ROUTINE或特权。如果您只有、 或 ,则为or字段EXECUTE显示的值 。 Create ProcedureCreate FunctionNULLCREATE 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_clientcharacter_set_client是创建例程时系统变量 的会话值。是创建例程时系统变量collation_connection的会话值。是与例程关联的数据库的排序规则。 collation_connectionDatabase Collation