How to say创建过程,如果在MySQL中不存在 [英] how to say create procedure if not exist in MySQL

查看:73
本文介绍了How to say创建过程,如果在MySQL中不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图编写一个脚本在MySQL数据库中创建一个过程,但是我想检查它是否首先存在.

I am trying to write a script to create a procedure in MySQL database, but I want to check if it exsit first.

我知道如何对表执行此操作,但是当我对存储过程使用相同的语法时,它不会编译.

I know how to do it for a table, but when I use the same syntax for stored procedure, it doesn't compile.

有人知道吗?谢谢

推荐答案

只需删除该过程(如果确实存在),然后重新添加即可:

Just drop the procedure if it does exist and then re-add it:

DROP PROCEDURE IF EXISTS my_procedure;
CREATE PROCEDURE my_procedure()

这篇关于How to say创建过程,如果在MySQL中不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆