0
0
SQLquery~20 mins

Why UPDATE needs caution in SQL - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
UPDATE Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
Effect of UPDATE without WHERE clause
Consider a table Employees with columns id, name, and salary. What will be the result after running this query?

UPDATE Employees SET salary = salary + 1000;

Assume the table initially has 3 rows with salaries 3000, 4000, and 5000.
SQL
UPDATE Employees SET salary = salary + 1000;
ANo salaries will change because WHERE clause is missing.
BOnly the first employee's salary will increase by 1000.
CAll 3 employees will have their salary increased by 1000.
DThe query will cause a syntax error.
Attempts:
2 left
💡 Hint
Think about what happens if you don't limit which rows to update.
query_result
intermediate
2:00remaining
UPDATE with incorrect WHERE condition
Given a table Products with columns product_id, price, and category, what will be the result of this query?

UPDATE Products SET price = price * 0.9 WHERE category = 'Electronics' AND price > 1000;

Assume only one product has category 'Electronics' but its price is 900.
SQL
UPDATE Products SET price = price * 0.9 WHERE category = 'Electronics' AND price > 1000;
AAll Electronics products will have their price reduced by 10%.
BThe query will update all products regardless of category.
COnly products with price less than 1000 will be updated.
DNo product prices will change because no product meets both conditions.
Attempts:
2 left
💡 Hint
Check if any product matches both conditions in WHERE.
📝 Syntax
advanced
2:00remaining
Identify the syntax error in UPDATE statement
Which option contains a syntax error in the UPDATE statement?
AUPDATE Orders SET status = 'Shipped' WHERE order_id = 10;
BUPDATE Products price = 20 WHERE product_id = 3;
CUPDATE Employees SET salary = salary + 500 WHERE department = 'Sales';
DUPDATE Customers SET city = 'Paris' WHERE id = 5;
Attempts:
2 left
💡 Hint
Look for missing keywords or punctuation.
🔧 Debug
advanced
2:00remaining
Unexpected data change after UPDATE
A developer runs this query:

UPDATE Inventory SET quantity = quantity - 1 WHERE product_id = 101;

But after running it, the quantity for all products decreased by 1. What is the most likely cause?
AThe WHERE clause was missing or incorrect, so all rows were updated.
BThe quantity column is not numeric, so subtraction failed.
CThe product_id 101 does not exist, so no rows updated.
DThe database automatically updates all rows when one is updated.
Attempts:
2 left
💡 Hint
Think about what happens if WHERE clause is ignored or wrong.
🧠 Conceptual
expert
2:00remaining
Why must UPDATE be used with caution in multi-user environments?
In a busy database with many users, why is it important to be cautious when running UPDATE statements?
ABecause UPDATE can lock rows or tables, causing delays or conflicts for other users.
BBecause UPDATE statements always delete data permanently.
CBecause UPDATE statements automatically create backups before changing data.
DBecause UPDATE statements cannot be rolled back once executed.
Attempts:
2 left
💡 Hint
Consider how databases handle multiple users changing data at the same time.