Stored procedures and Triggers Flashcards
what is a stored procedure
segments of declarative sql statements stored in the MySQL server
what is flow control
if case loops and calling other procedures
give the advantages of stored procedures (3)
minimises bandwidth (just call rather than write query)
consistency
security
give the disadvantages of stored procedures (3)
memory requirements
debugging is near impossible
specialised skillset
describe how a stored procedure is created
DELIMITER // CREATE PROCEDURE procedurename (IN con CHAR(20)) BEGIN … END // DELIMITER ;
how do you delete a stored procedure
drop
what are the 3 parameter nodes
IN
OUT
INOUT
describe IN parameters
have access to the values
describe OUT parameters
can change the value and pass it back
how do we alter a stored procedure
drop and start again
how do we create and set variables
DECLARE
SET
what is the MySQL cursor
allows you to iterate through a record set within a stored procedure
read only, linear
what is a trigger
a stored program that is invoked by an event
what events can trigger a trigger
INSERT UPDATE DELETE
how do we view all triggers
SHOW