Recall & Review
beginner
What is a variable in MySQL stored procedures?
A variable in MySQL stored procedures is a named memory location used to store data temporarily during the execution of the procedure. It helps hold values that can be changed and used in control flow statements.
Click to reveal answer
beginner
How do you declare a variable inside a MySQL stored procedure?
You declare a variable using the DECLARE statement followed by the variable name and data type, for example: DECLARE myVar INT; This must be done at the beginning of the procedure block.
Click to reveal answer
beginner
What is the purpose of the IF statement in MySQL?
The IF statement allows you to execute different blocks of code based on a condition. It helps control the flow by choosing which code runs depending on whether the condition is true or false.
Click to reveal answer
intermediate
Explain the WHILE loop in MySQL stored procedures.
The WHILE loop repeats a block of code as long as a specified condition remains true. It is useful for running repetitive tasks until a condition changes.
Click to reveal answer
intermediate
What is the difference between a local variable and a user-defined variable in MySQL?
A local variable is declared inside a stored procedure and only exists during its execution. A user-defined variable starts with @ and can be used outside procedures and persist for the session.
Click to reveal answer
How do you assign a value to a variable inside a MySQL stored procedure?
✗ Incorrect
You assign values to variables using the SET statement, for example: SET myVar = 10;
Which keyword starts a conditional block in MySQL stored procedures?
✗ Incorrect
The IF keyword starts a conditional block to execute code based on a condition.
What happens if the WHILE loop condition is false at the start?
✗ Incorrect
If the WHILE condition is false initially, the loop body does not execute.
Where must DECLARE statements appear in a MySQL stored procedure?
✗ Incorrect
DECLARE statements must be at the start of the procedure block before any other statements.
Which symbol is used to start a user-defined variable in MySQL?
✗ Incorrect
User-defined variables start with the @ symbol, like @myVar.
Describe how variables and control flow statements work together in a MySQL stored procedure.
Think about how you store values and decide what code runs next.
You got /4 concepts.
Explain the difference between DECLARE and SET statements in MySQL stored procedures.
One is for making space, the other is for putting things in that space.
You got /4 concepts.