what does delimiter do in a trigger

what does delimiter do in a trigger  using -'sql,mysql'

asked Sep 22, 2015 by amit_cmps
0 votes

4 Answers

0 votes

It changes the statement delimiter from ; to //. This is so you can write ; in your trigger definition without the MySQL client misinterpreting that as meaning you're done with it.

Note that when changing back, it's DELIMITER ;, not DELIMITER; as I've seen people try to do.

answered Sep 22, 2015 by android_master
0 votes

Read the (ummmm) mysql documentation.

delimiter is the marker for the end of each command you send to the mysql command line client.

delimiter is not only related to triggers, but defining triggers and stored procedures is one strong use case as you wish them to contain semicolons (;) which are otherwise the default delimiter.

answered Sep 22, 2015 by patilkiran.101
0 votes

In SQL you close each statement with a delimiter, which is by default a semicolon (;). In a trigger you need to write multiple statements, each ending in a semicolon. To tell MySQL that those semicolons are not the end of your trigger statement, you temporarily change the delimiter from ; to //, so MySQL will know that the trigger statement only ends when it econunters a //.

answered Sep 22, 2015 by rajeshujade
0 votes

Simple sets the end of statement delimiter (';' semi-colon in standard, default SQL). Changing the chracter could be useful if you want to use ';' in your SQL, or you are using embedded SQL (where it might lead to confusion). similarly the '//' in your example could lead to confusion in embedded SQL, or you might want to use it in your SQL. So imply use DELIMITER to set the delimiter that is appropriate for your application and needs.

answered Sep 22, 2015 by sujata naik