sql 例程与事件
sql routines vs events
我有一个数据库,我想每 24 小时执行一次 UPDATE 和 TRUNCATE 查询。我已经看到我无法将 SQL 语句组合成一个事件,这比有多个事件更容易。
我正在使用 phpMyAdmin,希望每 24 小时帮助执行以下语句。
TRUNCATE online_mentions;
TRUNCATE online_messages;
TRUNCATE user_views;
UPDATE forgot_password SET counter = 0;
UPDATE meta_tags SET views_daily = 0;
UPDATE post_tags SET daily=0;
UPDATE user_count SET views_daily = 0, followers_daily = 0, following_daily = 0, pages_daily = 0, logins_daily = 0;
UPDATE user_settings SET name = 0, password = 0, image = 0, questions = 0;
UPDATE xtrack_user_bio SET status_daily = 0, deletes_daily = 0, relationship_daily = 0;
UPDATE xtrack_user_chats SET chats_daily = 0, refresh_daily = 0, myChats_daily = 0, myMentions_daily = 0, men_daily = 0, women_daily = 0;
UPDATE xtrack_user_comments SET comments_daily = 0, edits_daily = 0, likes_daily = 0, dislikes_daily = 0, flags_daily = 0, deletes_daily = 0 ;
UPDATE xtrack_user_messages SET messages_daily = 0, refresh_daily = 0, flags_daily = 0, single_deletes_daily = 0, all_deletes_daily = 0;
UPDATE xtrack_user_posts SET posts_daily = 0, edits_daily = 0, likes_daily = 0, dislikes_daily = 0, flags_daily = 0, saves_daily = 0, deletes_daily = 0 ;
UPDATE xtrack_user_reports SET general_daily = 0, user_daily = 0, website_daily = 0;
UPDATE xtrack_user_settings SET username = 0, password = 0, image = 0, questions = 0;
通过添加BEGIN ... END
解决
BEGIN
TRUNCATE table_name;
TRUNCATE table_name;
TRUNCATE table_name;
END
我有一个数据库,我想每 24 小时执行一次 UPDATE 和 TRUNCATE 查询。我已经看到我无法将 SQL 语句组合成一个事件,这比有多个事件更容易。
我正在使用 phpMyAdmin,希望每 24 小时帮助执行以下语句。
TRUNCATE online_mentions;
TRUNCATE online_messages;
TRUNCATE user_views;
UPDATE forgot_password SET counter = 0;
UPDATE meta_tags SET views_daily = 0;
UPDATE post_tags SET daily=0;
UPDATE user_count SET views_daily = 0, followers_daily = 0, following_daily = 0, pages_daily = 0, logins_daily = 0;
UPDATE user_settings SET name = 0, password = 0, image = 0, questions = 0;
UPDATE xtrack_user_bio SET status_daily = 0, deletes_daily = 0, relationship_daily = 0;
UPDATE xtrack_user_chats SET chats_daily = 0, refresh_daily = 0, myChats_daily = 0, myMentions_daily = 0, men_daily = 0, women_daily = 0;
UPDATE xtrack_user_comments SET comments_daily = 0, edits_daily = 0, likes_daily = 0, dislikes_daily = 0, flags_daily = 0, deletes_daily = 0 ;
UPDATE xtrack_user_messages SET messages_daily = 0, refresh_daily = 0, flags_daily = 0, single_deletes_daily = 0, all_deletes_daily = 0;
UPDATE xtrack_user_posts SET posts_daily = 0, edits_daily = 0, likes_daily = 0, dislikes_daily = 0, flags_daily = 0, saves_daily = 0, deletes_daily = 0 ;
UPDATE xtrack_user_reports SET general_daily = 0, user_daily = 0, website_daily = 0;
UPDATE xtrack_user_settings SET username = 0, password = 0, image = 0, questions = 0;
通过添加BEGIN ... END
BEGIN
TRUNCATE table_name;
TRUNCATE table_name;
TRUNCATE table_name;
END