Home > Database > Mysql Tutorial > body text

How to Create Stored Procedures in phpMyAdmin without Changing the Delimiter?

Mary-Kate Olsen
Release: 2024-11-02 23:50:30
Original
164 people have browsed it

How to Create Stored Procedures in phpMyAdmin without Changing the Delimiter?

Creating Stored Procedures in phpMyAdmin

Adding stored procedures to a MySQL database from phpMyAdmin can be challenging as it doesn't offer the option to change the delimiter. However, there is a workaround:

Step-by-Step Process:

  1. Visit the URL provided in the response: http://blog.nth-design.com/2009/02/25/creating-sp-in-phpmyadmin/.
  2. Follow the steps outlined on the webpage:

    • Open phpMyAdmin and select the target database.
    • Navigate to the SQL tab.
    • Select the SQL statements between the "DELIMITER" statements in the stored procedure script, excluding the "DELIMITER" statements themselves.
    • Set the delimiter to "$$" in the delimiter field below the SQL editor's text area.
  3. Execute the modified SQL code, which will create the stored procedure in the database.

Example:

Let's consider the following stored procedure:

<code class="sql">DROP PROCEDURE IF EXISTS spFoo $$
CREATE PROCEDURE spFoo ()
BEGIN
    SELECT 'Foo' FROM DUAL;
END $$</code>
Copy after login

To create this stored procedure in phpMyAdmin using the workaround:

  • Select all the SQL statements between "DELIMITER" and "$$", excluding the "DELIMITER" statements:
<code class="sql">DROP PROCEDURE IF EXISTS spFoo
CREATE PROCEDURE spFoo ()
BEGIN
    SELECT 'Foo' FROM DUAL;
END</code>
Copy after login
  • Set the delimiter to "$$" in the delimiter field below the SQL editor.
  • Execute the modified SQL code.

The above is the detailed content of How to Create Stored Procedures in phpMyAdmin without Changing the Delimiter?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!