Mysql中delimiter作用

來源:互聯網
上載者:User

1. delimiter
delimiter是mysql分隔字元,在mysql用戶端中分隔字元預設是分號(;)。如果一次輸入的語句較多,並且語句中間有分號,這時需要新指定一個特殊的分隔字元。
2. delimiter使用
在前一篇中有設定mysql的觸發器時使用例子

mysql> delimiter //mysql> create trigger upd_check before update on account     -> for each row    -> begin    -> if new.amount < 0 then    ->  set new.amount=0;    -> elseif new.amount > 100 then    ->  set new.amount = 100;    -> end if;    -> end;    -> //Query OK, 0 rows affected (0.00 sec)mysql> delimiter ;

上面就是,先將分隔字元設定為 //, 直到遇到下一個 //,才整體執行語句。執行完後,最後一行, delimiter ; 將mysql的分隔字元重新設定為分號;如果不修改的話,本次會話中的所有分隔字元都以// 為準。
地址:http://blog.csdn.net/yonggang7/article/details/24558385



相關文章

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.