简体   繁体   English

如何从phpmyadmin导出和导入存储过程

[英]how to export and import stored procedures from phpmyadmin

Can you guys help me out regarding stored procedures. 关于存储过程,你能帮助我吗? When I export stored procedure from phpmyadmin, It given as 当我从phpmyadmin导出存储过程时,它给出为

CREATE DEFINER=`root`@`localhost` PROCEDURE `c4mo_get_cities_prc`(IN `p_state_code` VARCHAR(3), IN `p_country_code` VARCHAR(3), IN `p_language_code` VARCHAR(3))
    NO SQL
BEGIN

SELECT city_name, city_code
FROM `c4mo_cities` 
WHERE enabled = 'Y' 
AND language_code = p_language_code
AND state_code = p_state_code
AND country_code = p_country_code;

END

And when I import it from phpmyadmin, it giving error as 当我从phpmyadmin导入它时,它会给出错误

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 13 

Copy the exported stored procedure to file eg myprocedure.sql. 将导出的存储过程复制到文件,例如myprocedure.sql。 Now modify that .sql file with following: 1) Remove DEFINER= root @ localhost 2) At the beginning of stored procedure add delimiter definition. 现在修改.sql文件,如下所示:1)删除DEFINER = root @ localhost 2)在存储过程开始时添加分隔符定义。 and at the end reset delimiter. 并在结束时重置分隔符。

eg 例如

`DELIMITER $$
`CREATE  PROCEDURE `c4mo_get_cities_prc`(IN `p_state_code` VARCHAR(3), IN 
`p_country_code` VARCHAR(3), IN `p_language_code` VARCHAR(3))
NO SQL
BEGIN

SELECT city_name, city_code
FROM `c4mo_cities` 
WHERE enabled = 'Y' 
AND language_code = p_language_code
AND state_code = p_state_code
AND country_code = p_country_code;

END $$
DELIMITER ;

After that import stored procedure just like any other database you import by selecting .sql file. 之后导入存储过程就像您导入的任何其他数据库一样,选择.sql文件。

Thank you 谢谢

Remove DEFINER= root @ localhost 删除DEFINER = root @ localhost

in local while import, 在本地进口时,

it will execute. 它会执行。

It quite simple if you use phpmyadmin interface. 如果你使用phpmyadmin接口,这很简单。

For export : 出口

You will see a routine tab as this tab will be shown only when you will already have at least one stored procedure. 您将看到一个例程选项卡,因为只有当您已经拥有至少一个存储过程时,才会显示此选项卡。

Just Click on routines tab and you will see your made stored procedure(For the db , you have made). 只需单击例程选项卡,您将看到您创建的存储过程(对于您已创建的数据库)。

At below, tick check all on check Box and then export , You just need to copy the whole code and save it to anywhere on your local machine with your_stored_procedure.sql file. 在下面,勾选勾选复选框然后导出,您只需复制整个代码并使用your_stored_procedure.sql文件将其保存到本地计算机上的任何位置。

For import: 进口:

Just select the database and import your stored procedure your_stored_procedure.sql file as mentioned above, as you generally import .sql file(tables) for your db. 只需选择数据库并导入存储过程your_stored_procedure.sql文件,如上所述,因为您通常导入数据库的.sql文件(表)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM