有人能告诉我为什么我的语法错了吗?
我将分隔符设置为$$ do prevent;成为一个问题。我不想创建表格,截断是好的。
DELIMITER $$
create procedure create persistent_views
begin
truncate table vwt_total_overview_last3days;
truncate table vwt_total_overview_last30days:
truncate table vwt_total_overview_last7days;
truncate table vwt_total_overview_lastday;
insert into vwt_total_overview_last3days
select * from total_overview_last3days;
insert into vwt_total_overview_last30days
select * from total_overview_last30days;
insert into vwt_total_overview_last7days
select * from total_overview_last7days;
insert into vwt_total_overview_lastday
select * from total_overview_lastday;
END $$
我得到了:
#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 'create persistent_views begin truncate table vwt_total_overview_last3days; trun' at line 1
我将声明更改为以下内容,但它也无效(尝试使用和不使用parens和AS)
DELIMITER $$
create procedure persistent_views() AS
begin
truncate table vwt_total_overview_last3days;
truncate table vwt_total_overview_last30days:
truncate table vwt_total_overview_last7days;
truncate table vwt_total_overview_lastday;
insert into vwt_total_overview_last3days
select * from total_overview_last3days;
insert into vwt_total_overview_last30days
select * from total_overview_last30days;
insert into vwt_total_overview_last7days
select * from total_overview_last7days;
insert into vwt_total_overview_lastday
select * from total_overview_lastday;
END $$
答案 0 :(得分:0)
您已使用CREATE
字两次。只需删除第二个。这可能会解决你的问题。之后是一对paranthesis和AS
关键字。
答案 1 :(得分:0)
好的,我自己解决了。一个半结肠,实际上是结肠......
正确的语法是:
DELIMITER $$
create procedure persistentViews()
BEGIN
truncate table vwt_total_overview_last3days;
truncate table vwt_total_overview_last30days;
truncate table vwt_total_overview_last7days;
truncate table vwt_total_overview_lastday;
insert into vwt_total_overview_last3days
select * from total_overview_last3days;
insert into vwt_total_overview_last30days
select * from total_overview_last30days;
insert into vwt_total_overview_last7days
select * from total_overview_last7days;
insert into vwt_total_overview_lastday
select * from total_overview_lastday;
END $$