gpt4 book ai didi

mysql创建一个简单的程序

转载 作者:行者123 更新时间:2023-11-29 12:19:43 26 4
gpt4 key购买 nike

我很困惑...为什么下面的代码失败? MySQL 5.6。我想创建简单的过程来删除某些表中的数据

DROP PROCEDURE IF EXISTS truncateStaging;
create procedure truncateStaging
begin
delete from stg_user;
delete from stg_userflag;
end;
PROCEDURE test.truncateStaging does not exist
procedure IF dropped.
Error starting at line : 3 in command -
create procedure truncateStaging
begin
delete from stg_user;
delete from stg_userflag;
end;
Error report -
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 'begin
delete from stg_user;
delete from stg_userflag;
end' at line 2

最佳答案

首先您需要更改分隔符,其次您忘记了过程定义中的 ()

DROP PROCEDURE IF EXISTS truncateStaging;
delimiter |
create procedure truncateStaging()
begin
delete from stg_user;
delete from stg_userflag;
end
|
delimiter ;

关于mysql创建一个简单的程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29206480/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com