Recall & Review
beginner
What does the
UPDATE statement do in SQL?The
UPDATE statement changes existing data in a table by modifying one or more columns for rows that match a condition.Click to reveal answer
beginner
Why is the
WHERE clause important in an UPDATE statement?The
WHERE clause limits which rows get updated. Without it, all rows in the table will be changed.Click to reveal answer
beginner
Write the basic syntax of an
UPDATE statement with a WHERE condition.UPDATE table_name SET column1 = value1, column2 = value2 WHERE condition;
Click to reveal answer
intermediate
What happens if you run
UPDATE employees SET salary = 5000; without a WHERE clause?All rows in the
employees table will have their salary set to 5000, which might not be what you want.Click to reveal answer
beginner
How can you update only the rows where the employee's department is 'Sales'?
Use a
WHERE clause to specify the condition: <br>UPDATE employees SET salary = 6000 WHERE department = 'Sales';
Click to reveal answer
What does the
WHERE clause do in an UPDATE statement?✗ Incorrect
The
WHERE clause filters rows so only matching rows get updated.What happens if you omit the
WHERE clause in an UPDATE statement?✗ Incorrect
Without
WHERE, the update applies to every row in the table.Which SQL keyword is used to specify the new values in an
UPDATE statement?✗ Incorrect
The
SET keyword defines the columns and their new values.How would you update the 'status' column to 'active' only for users with 'id' 10?
✗ Incorrect
The correct syntax places
SET before WHERE.Which of these is a valid
UPDATE statement?✗ Incorrect
Option A uses correct syntax:
UPDATE table SET column = value WHERE condition;Explain how the
UPDATE statement works with a WHERE condition in SQL.Think about how you tell SQL which rows to change and what to change.
You got /3 concepts.
Describe what could happen if you forget the
WHERE clause in an UPDATE statement.Imagine changing every item in a list by mistake.
You got /3 concepts.