如何创建日常触发器会自动执行此查询?
insert into deliverability.test_month (type,from_sale)
select type,from_sale
from deliverability.delivery_money_repo
where total = 100
答案 0 :(得分:2)
创建一个包含代码的存储过程,并像下面的
一样调用它CREATE PROCEDURE Daily_Insertion
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
insert into deliverability.test_month (type,from_sale)
select type,from_sale
from deliverability.delivery_money_repo
where total = 100
END
然后将其设置为每天运行
CREATE EVENT myevent
ON SCHEDULE EVERY 1 DAY
DO
CALL Daily_Insertion