This is a read-only copy of the MariaDB Knowledgebase generated on 2024-11-14. For the latest, interactive version please visit https://mariadb.com/kb/.

SHOW CREATE PROCEDURE

Syntax

SHOW CREATE PROCEDURE proc_name

Description

This statement is a MariaDB extension. It returns the exact string that can be used to re-create the named stored procedure, as well as the SQL_MODE that was used when the trigger has been created and the character set used by the connection.. A similar statement, SHOW CREATE FUNCTION, displays information about stored functions.

Both statements require that:

When none of the above statements are true, the statements display NULL for the Create Procedure or Create Function field.

Warning Users with SELECT privileges on mysql.proc or USAGE privileges on *.* can view the text of routines, even when they do not have privileges for the function or procedure itself.

SHOW CREATE PROCEDURE quotes identifiers according to the value of the sql_quote_show_create system variable. Prior to MariaDB 10.6.5, MariaDB 10.5.13 and MariaDB 10.4.22, the output of this statement was unreliably affected by the sql_quote_show_create system variable.

Examples

Here's a comparison of the SHOW CREATE PROCEDURE and SHOW CREATE FUNCTION statements.

SHOW CREATE PROCEDURE test.simpleproc\G
*************************** 1. row ***************************
           Procedure: simpleproc
            sql_mode: 
    Create Procedure: CREATE PROCEDURE `simpleproc`(OUT param1 INT)
                      BEGIN
                      SELECT COUNT(*) INTO param1 FROM t;
                      END
character_set_client: latin1
collation_connection: latin1_swedish_ci
  Database Collation: latin1_swedish_ci

SHOW CREATE FUNCTION test.hello\G
*************************** 1. row ***************************
            Function: hello
            sql_mode:
     Create Function: CREATE FUNCTION `hello`(s CHAR(20))
                      RETURNS CHAR(50)
                      RETURN CONCAT('Hello, ',s,'!')
character_set_client: latin1
collation_connection: latin1_swedish_ci
  Database Collation: latin1_swedish_ci

When the user issuing the statement does not have privileges on the routine, attempting to CALL the procedure raises Error 1370.

CALL test.prc1();
Error 1370 (42000): execute command denied to 
  user 'test_user'@'localhost' for routine 'test'.'prc1'

If the user neither has privilege to the routine nor the SELECT privilege on mysql.proc table, it raises Error 1305, informing them that the procedure does not exist.

SHOW CREATE TABLES test.prc1\G
Error 1305 (42000): PROCEDURE prc1 does not exist

See Also

Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.