可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I created a stored procedure in 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?
回答1:
View stored procedures in 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.
The routines
option 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 routines
link under structure
tab.
回答2:
select routine_definition
from information_schema.routines
where routine_schema = 'db_name'
and routine_name = 'sp_name';
回答3:
This answer shows 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."
回答4:
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.
回答5:
In short you can use this sql
SHOW CREATE PROCEDURE Sample;
More information here
- http://dev.mysql.com/doc/refman/5.0/en/show-create-procedure.html
- http://dev.mysql.com/doc/refman/5.0/en/faqs-stored-procs.html#qandaitem-B-4-1-6
UPDATE: If you don't remember the names, you can query the INFORMATION_SCHEMA
database to see all the procedures (well you can use a LIKE on ROUTINE_NAME
, if you remember a partial name)
SELECT ROUTINE_TYPE, ROUTINE_NAME, ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_SCHEMA='dbname';
回答6:
under phpMyAdmin, click on your database (Not on the table), then click on "+Routines".
There you can edit/drop all your stored procedures
回答7:
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.
回答8:
In PHPMYADMIN 3.5.2.2 version you just click on routines link in top. See the attached image
回答9:
After clicking home, databases, the database I created the procedure in. It opens the structure window of that database.
In the menu bar: "structure, sql, search ,..." there should be routines, if it's not then click on the right item called more and it should be there (curse my netbook for not having a 24 inch screen).
To make sure your database has the procedure click on export, choose "Custom - display all possible options", under "Output:" choose "View output as text", under "Format-specific options:" choose "structure" (just under "dump table"),make sure "Add CREATE PROCEDURE / FUNCTION / EVENT statement" is selected (just a little under "dump table").
Now click Go and your procedure should show up
using:
Version information: 3.5.2, latest stable version: 3.5.2.2
回答10:
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).
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.
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).
-- edit --
For completeness, you may also list stored procedures with this SQL query:
show procedure status;
Or this one, to retrieve a procedure whose name is known:
show procedure status where Name = 'name';
回答11:
Don't forget that in smaller screens you'll have to use the "more" menu.