MySQL 如何在 phpMyAdmin 中查看我的存储过程?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6115573/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 20:00:20  来源:igfitidea点击:

How do I view my stored procedures in phpMyAdmin?

mysqlsqlstored-proceduresphpmyadmin

提问by Dennis Martinez

I created a stored procedure in phpMyAdmin

我在 phpMyAdmin 中创建了一个存储过程

CREATE PROCEDURE Sample()
SELECT * FROM feedback

Where could I view this this procedure? If it's not possible in phpMyAdmin, what is/are some good program(s) that have the feature to write, store, and view stored procedures, tables, etc?

我在哪里可以看到这个程序?如果在 phpMyAdmin 中不可能,那么有哪些好的程序可以编写、存储和查看存储过程、表等?

回答by ravi404

View stored procedures in phpmyadmin:

在phpmyadmin中查看存储过程:

Query:

询问:

SELECT routine_definition
FROM information_schema.routines
WHERE 
routine_name = 'procedure_name' AND routine_schema = 'databasename';

Here's how to get there in phpmyadmin.

这是在 phpmyadmin 中到达那里的方法。

phpmyadmin screenshot

phpmyadmin 截图

The routinesoption is available in phpmyadmin. The link is not visible in PHPmyadmin until you have at least one stored procedure. See the above image and click the routineslink under structuretab.

routines选项在phpmyadmin. 在您至少拥有一个存储过程之前,该链接在 PHPmyadmin 中不可见。查看上图并单击选项卡routines下的链接structure

回答by Nicola Cossu

select routine_definition
from information_schema.routines
where routine_schema = 'db_name'
and routine_name = 'sp_name';

回答by Luis Felipe Barnett V

This answershows how to view them without a script.

这个答案显示了如何在没有脚本的情况下查看它们。

"Once you created the stored procedure it will appear in the Routines fieldset below your tables (in the Structure tab), and you can easily change/drop it."

“创建存储过程后,它将出现在表下方的例程字段集中(在结构选项卡中),您可以轻松更改/删除它。”

回答by steffen

You can select "information_schema" as database and query all entries form the table "routines", in case u don't want to use SQL everytime.

您可以选择“information_schema”作为数据库并从“routines”表中查询所有条目,以防您不想每次都使用 SQL。

回答by Aravindan R

In short you can use this sql

总之你可以使用这个sql

SHOW CREATE PROCEDURE Sample;

More information here

更多信息在这里

UPDATE: If you don't remember the names, you can query the INFORMATION_SCHEMAdatabase to see all the procedures (well you can use a LIKE on ROUTINE_NAME, if you remember a partial name)

更新:如果您不记得名称,您可以查询INFORMATION_SCHEMA数据库以查看所有程序(ROUTINE_NAME如果您记得部分名称,您可以使用 LIKE on )

SELECT ROUTINE_TYPE, ROUTINE_NAME, ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_SCHEMA='dbname';

回答by Karim

under phpMyAdmin, click on your database (Not on the table), then click on "+Routines".

在 phpMyAdmin 下,单击您的数据库(不在表上),然后单击“+Routines”。

There you can edit/drop all your stored procedures

在那里您可以编辑/删除所有存储过程

回答by Rene Meulenbroek

show procedure status;      -- will show you the stored procedures.
show create procedure MY_PROC;  -- will show you the definition of a procedure. 
help show;          -- show all the available options for the show command.

回答by Mahadeva Prasad

In PHPMYADMIN enter image description here3.5.2.2 version you just click on routines link in top. See the attached image

在 PHPMYADMIN 在此处输入图片说明3.5.2.2 版本中,您只需单击顶部的例程链接。见附件图片

回答by Rodrigo Polo

Don't forget that in smaller screens you'll have to use the "more" menu. phpMyAdmin

不要忘记,在较小的屏幕中,您必须使用“更多”菜单。 phpMyAdmin

回答by Hibou57

Use the Adminer data-base interface. Unlike PHPMyAdmin, it's perfectly able to view, edit and invoke stored procedures, where PHPMyAdmin fails with tons of errors (errors when you try to run an SQL statement to create one, errors when you try to invoke one, errors when you try to alter one already created, beside of its inability to list the ones defined… I really wonder what PHPMyAdmin do with with SQL queries text before it submit it to the DB, that's frightening).

使用Adminer 数据库界面。与 PHPMyAdmin 不同,它完全能够查看、编辑和调用存储过程,其中 PHPMyAdmin 失败并出现大量错误(尝试运行 SQL 语句创建一个时出错,尝试调用时出错,尝试更改时出错)一个已经创建的,除了无法列出定义的那些……我真的很想知道 PHPMyAdmin 在将 SQL 查询文本提交到数据库之前对它做了什么,这太可怕了)。

Just copy the Adminer PHP file at some location of you web server, open the corresponding URL. After you logged-in and selected a data-base, below the list of tables, you will see a list of the stored procedures, with a Call button. Clicking on the procedure link, you will also be able to alter (edit) it.

只需将 Adminer PHP 文件复制到您的 Web 服务器的某个位置,打开相应的 URL。在您登录并选择一个数据库后,在表列表下方,您将看到一个存储过程列表,带有一个调用按钮。单击程序链接,您还可以更改(编辑)它。

Honestly, I recommand you gave up with PHPMyAdmin, it's perfectly incapable of properly dealing with this (note that SQLBuddy too, fails in some way with that).

老实说,我建议你放弃 PHPMyAdmin,它完全无法正确处理这个问题(注意 SQLBuddy 也是如此,在某种程度上失败了)。

-- edit --

- 编辑 -

For completeness, you may also list stored procedures with this SQL query:

为了完整起见,您还可以使用此 SQL 查询列出存储过程:

show procedure status;

Or this one, to retrieve a procedure whose name is known:

或者这个,以检索名称已知的过程:

show procedure status where Name = 'name';