mhpreiman
12/9/2016 - 7:48 AM

mysql unfinished notes

http://softwareengineering.stackexchange.com/questions/123074/sql-triggers-and-when-or-when-not-to-use-them/123628#123628
http://stackoverflow.com/questions/3744209/mysql-stored-procedure-vs-function-which-would-i-use-when
https://dev.mysql.com/doc/sakila/en/
https://dev.mysql.com/doc/sakila/en/sakila-structure-functions-inventory_held_by_customer.html
https://dev.mysql.com/doc/index-other.html

Trigger is a special type of stored procedure that fires as a response of an event rather than be directly executed by the user like a normal procedure.
Commonly used for auditing.
Row and statement triggers
What to keep in mind using triggers

Procedures vs functions:

  • (stored) functions can be used in ordinary SQL, procedures can't
  • procedure doesn't return a value. it's invoked (called) to perform an operation (like modifying a table, processing retrieved records ..)
  • while function returns a single value directly to the caller to be used in the expression

Prepared statements for faster performance

  • can be used in procedures, but not functions or triggers