SHOW CREATE PROCEDURE proc_name
这个语句是一个 MySQL 扩展。它返回可用于重新创建命名存储过程的确切字符串。类似的语句,SHOW CREATE
FUNCTION
显示有关存储函数的信息(请参阅第 13.7.5.8 节,“SHOW CREATE FUNCTION 语句”)。
要使用任一语句,您必须是例程DEFINER
子句中指定的用户或有权
SELECT
访问该
mysql.proc
表。如果您没有例程本身的权限,则为
Create Procedure
或Create
Function
列显示的值为NULL
。
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_AUTO_CREATE_USER,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: utf8
collation_connection: utf8_general_ci
Database Collation: latin1_swedish_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_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
Create Function: CREATE DEFINER=`me`@`localhost`
FUNCTION `hello`(s CHAR(20))
RETURNS char(50) CHARSET latin1
DETERMINISTIC
RETURN CONCAT('Hello, ',s,'!')
character_set_client: utf8
collation_connection: utf8_general_ci
Database Collation: latin1_swedish_ci
character_set_client
character_set_client
是创建例程时系统变量
的会话值。是创建例程时系统变量collation_connection
的会话值。是与例程关联的数据库的排序规则。
collation_connection
Database
Collation