Programmatic SQL Flashcards

1
Q

What is a procedure in MySQL?

A

A stored routine that has to be called in the SQL code

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

What is a function in MySQL?

A

A stored routine that returns a value, it is not called and instead appears as or as part of an expression

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

What is a trigger in MySQL?

A

A stored routine that takes place when a particular event occurs

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

What is the syntax of a procedure?

A
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>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the syntax of a function?

A
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>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the syntax of a trigger?

A
CREATE TRIGGER <trigger-name>  
(BEFORE | AFTER) <event-type>  
ON <which-table>  
FOR EACH ROW  
BEGIN  
<block-of-actions>  
END
How well did you know this?
1
Not at all
2
3
4
5
Perfectly