triggers_procedures_flashcards

1
Q

What is a stored procedure?

A

Procedural SQL code stored in the database, executed with a CALL statement.

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

What is a trigger?

A

A procedure that automatically executes in response to certain events on a table.

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

When do triggers execute?

A

On INSERT, UPDATE, or DELETE events.

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

What are the components of a trigger?

A

Trigger event, timing (BEFORE/AFTER), and level (ROW/STATEMENT).

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

How do you declare a procedure in MySQL?

A

Using CREATE PROCEDURE with input/output parameters and a BEGIN…END block.

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

What is the difference between a procedure and a trigger?

A

Procedures are called manually; triggers are event-driven.

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

What is the use of DELIMITER in MySQL?

A

To change the statement terminator when defining procedures or triggers.

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

What is NEW and OLD in triggers?

A

Pseudo-records to reference column values before/after a change.

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