laika222
12/2/2016 - 3:02 AM

The DELIMITER is what separates statements and executes them. There are times where you'll want to enter a block of statements together and

The DELIMITER is what separates statements and executes them. There are times where you'll want to enter a block of statements together and execute them together, such as when you're putting together a procedure. To do this, use DELIMITER to change the DELIMITER from ; to another character or string. Below, line 1 changes the DELMITER to '$'. Lines 4 and 5 show the multiple statements in the procedure. The block is executed in line 6 when the new DELIMITER '$' is entered. Line 7 changes the DELIMITER back to ';'.

DELIMITER $
CREATE PROCEDURE show_times()
BEGIN
  SELECT 'Local time is:', CURRENT_TIMESTAMP;
  SELECT 'UTC time is:',UTC_TIMESTAMP;
END $
DELIMITER ;