mysql觸發器_begin end 執行多次語句

來源:互聯網
上載者:User

標籤:blog   io   for   資料   ar   div   log   new   

//多SQL中匯出的觸發器語句:DROP TRIGGER IF EXISTS `t_trig`;DELIMITER //CREATE TRIGGER `t_trig` BEFORE INSERT ON `t_goods` FOR EACH ROW beginset NEW.add_date = current_date();INSERT INTO test2 SET a2 = NEW.id;end//DELIMITER ;/************************************************ ************************************************ ************************************************///在刪除一個終端調研時觸發刪除銷售體驗和競品分析DELIMITER //CREATE TRIGGER`delete_assistant_research` BEFORE DELETE ON `tb_assistant_research`FOR EACH ROW beginDELETE FROM `tb_assistant_experience` WHERE `research_id` = old.id;DELETE FROM `tb_assistant_compete_analyse` WHERE `research_id` = old.id;end//DELIMITER;/************************************************ ************************************************ ************************************************///在刪除一個競品商品時, 刪除該競品商品的競品分析資料DELIMITERCREATE TRIGGER `delete_product` AFTER DELETE ON`tb_assistant_compete_product`FOR EACH ROW beginDELETE FROM `tb_assistant_compete_analyse` WHERE `product_id` = old.id;endDELIMITER;/************************************************ ************************************************ ************************************************///在刪除某一家門店時,刪除該門店的巡店和終端調研//本機伺服器118所需要的觸發器語句DROP TRIGGER IF EXISTS `delete_assistant_store`;DELIMITER //CREATE TRIGGER`delete_assistant_store` AFTER DELETE ON `tb_assistant_store`FOR EACH ROW beginDELETE FROM `tb_assistant_visitstore` WHERE `store_id` = old.id;DELETE FROM `tb_assistant_research` WHERE `store_id` = old.id;end//DELIMITER;遠程伺服器:121.199.167.212所匯出的觸發器DROP TRIGGER IF EXISTS `delete_assistant_store`//CREATE TRIGGER `delete_assistant_store` AFTER DELETE ON `tb_assistant_store` FOR EACH ROW beginDELETE FROM `tb_assistant_visitstore` WHERE `store_id` = old.id;DELETE FROM `tb_assistant_research` WHERE `store_id` = old.id;end///************************************************ ************************************************ ************************************************/在刪除某一個流程時,需要刪除對應該流程的備忘資訊sign=1刪除巡店 sign=2刪除銷售體驗 sign=3刪除競品分析//以後用標準格式DROP TRIGGER IF EXISTS `delete_assistant_option`;delimiter //CREATE TRIGGER`delete_assistant_option` AFTER DELETE ON `tb_assistant_option`FOR EACH ROW BEGINIF old.sign=1 THEN  DELETE FROM `tb_assistant_visitstore_message` WHERE `option_id` = old.id;ELSEIF old.sign=2 THEN  DELETE FROM `tb_assistant_experience_message` WHERE `option_id` = old.id;ELSEIF old.sign=3 THEN  DELETE FROM `tb_assistant_compete_analyse_message` WHERE `option_id` = old.id;END IF;END;//delimiter ;標準格式,版主給的delimiter //CREATE TRIGGER testref BEFORE INSERT ON test1  FOR EACH ROW BEGIN    INSERT INTO test2 SET a2 = NEW.a1;    DELETE FROM test3 WHERE a3 = NEW.a1;    UPDATE test4 SET b4 = b4 + 1 WHERE a4 = NEW.a1;  END;//delimiter ;

  

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.