Stored procedures and Triggers Flashcards

1
Q

what is a stored procedure

A

segments of declarative sql statements stored in the MySQL server

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what is flow control

A

if case loops and calling other procedures

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

give the advantages of stored procedures (3)

A

minimises bandwidth (just call rather than write query)

consistency

security

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

give the disadvantages of stored procedures (3)

A

memory requirements

debugging is near impossible

specialised skillset

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

describe how a stored procedure is created

A
DELIMITER //
CREATE PROCEDURE procedurename
(IN con CHAR(20))
BEGIN
    …
END //
DELIMITER ;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

how do you delete a stored procedure

A

drop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what are the 3 parameter nodes

A

IN
OUT
INOUT

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

describe IN parameters

A

have access to the values

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

describe OUT parameters

A

can change the value and pass it back

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

how do we alter a stored procedure

A

drop and start again

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

how do we create and set variables

A

DECLARE

SET

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

what is the MySQL cursor

A

allows you to iterate through a record set within a stored procedure

read only, linear

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

what is a trigger

A

a stored program that is invoked by an event

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

what events can trigger a trigger

A

INSERT UPDATE DELETE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

how do we view all triggers

A

SHOW

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

describe how a trigger is created

A
CREATE TRIGGER name
BEFORE/AFTER INSERT/UPDATE/DELETE ON table
      BEGIN
       …
      END;
17
Q

what are the new and old modifiers

A

we put in front of a variable to describe what we want to look at e.g. NEW.name and OLD.name

18
Q

when would we use a before trigger

A

to check values before a change is made

19
Q

when would we use an after trigger

A

to make changes in response to an update or similar

20
Q

how do we daisy chain triggers

A

by specifying follows or precedes