What is a procedure in MySQL?
A stored routine that has to be called in the SQL code
What is a function in MySQL?
A stored routine that returns a value, it is not called and instead appears as or as part of an expression
What is a trigger in MySQL?
A stored routine that takes place when a particular event occurs
What is the syntax of a procedure?
CREATE PROCEDURE <proc-name> ( [IN|OUT|INOUT] <param-1> <type-1>, ... , [IN|OUT|INOUT] <param-n> <type-n> ) BEGIN [ DECLARE <var-name-1> <type-1>; ...] /*local variables*/ <body> /*SQL statements*/ END <delimiter-sym>
What is the syntax of a function?
CREATE FUNCTION <func-name>( <param-1><type-1>, ... ,<param-n><type-n>) RETURNS <return-type> BEGIN [ DECLARE <var-name-1> <type-1>; ...] <body> RETURN <expression>; END <delimiter-sym>
What is the syntax of a trigger?
CREATE TRIGGER <trigger-name> (BEFORE | AFTER) <event-type> ON <which-table> FOR EACH ROW BEGIN <block-of-actions> END