SHOW CREATE PROCEDURE procedure_name不显示过程内容

时间:2017-12-15 08:24:25

标签: mysql linux database stored-procedures mysql-workbench

您好我正在努力解决我必须查看存储过程内容的问题我已经发出命令来获取过程的名称

mysql> SHOW PROCEDURE STATUS;
+-----+---------------------------------+-----------+-----------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+
| Db  | Name                            | Type      | Definer   | Modified            | Created             | Security_type | Comment | character_set_client | collation_connection | Database Collation |
+-----+---------------------------------+-----------+-----------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+
| vmp | ccontrol_table | PROCEDURE | user1@% | 2015-11-10 01:01:51 | 2015-11-10 01:01:51 | DEFINER       |         | utf8                 | utf8_general_ci      | latin1_swedish_ci  |
+-----+---------------------------------+-----------+-----------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+
1 row in set (0.27 sec)

它显示程序存在,名称为 control_table 要查看我使用 SHOW CREATE PROCEDURE control_table 的程序,它将以此格式显示,而不是内容

mysql> SHOW CREATE PROCEDURE control_table;
+---------------+----------+------------------+----------------------+----------------------+--------------------+
| Procedure     | sql_mode | Create Procedure | character_set_client | collation_connection | Database Collation |
+---------------+----------+------------------+----------------------+----------------------+--------------------+
| control_table |          | NULL             | utf8                 | utf8_general_ci      | latin1_swedish_ci  |
+---------------+----------+------------------+----------------------+----------------------+--------------------+
1 row in set (0.28 sec)

我已执行此使用MySQL客户端和mySQL Client Workbench,无法查看过程

2 个答案:

答案 0 :(得分:1)

程序存储在information_schema.routines中。 show create在这里看到一个用于control_table的条目,但是routine_definition是空的 - 这表明有人修改了information_schema.routines。您可以通过简单的选择 -

来检查information_schema.routines的内容
select routine_name,routine_definition 
from information_schema.ROUTINES
where routine_name = 'control_table'

==这是输出=====

mysql> select routine_name,routine_definition 
    -> from information_schema.ROUTINES
    -> where routine_name = 'control_table'
    -> ;
+---------------------------------+--------------------+
| routine_name                    | routine_definition |
+---------------------------------+--------------------+
| control_table | NULL               |
+---------------------------------+--------------------+
1 row in set (0.28 sec)

答案 1 :(得分:0)

如果您需要更新没有标准SQL指令(DROP / CREATE PROCEDURE)的正文,您可以使用以下指令:

UPDATE  mysql.proc SET body='begin select 2 from dual; end' WHERE `name` = 'control_table';