The UPDATE statement changes existing data in one or more rows of a table based on a condition.
Click to reveal answer
beginner
Why should you be careful when using UPDATE without a WHERE clause?
Without a WHERE clause, UPDATE changes every row in the table, which can cause unintended data loss or corruption.
Click to reveal answer
intermediate
How can you prevent accidental updates to all rows?
Always use a precise WHERE clause to target only the rows you want to change, and consider running a SELECT first to check which rows will be affected.
Click to reveal answer
beginner
What is a common mistake when writing UPDATE statements?
A common mistake is forgetting the WHERE clause or having a wrong condition, which updates more rows than intended.
Click to reveal answer
intermediate
What should you do before running a risky UPDATE?
Make a backup or run the UPDATE inside a transaction so you can undo changes if something goes wrong.
Click to reveal answer
What happens if you run UPDATE without a WHERE clause?
AThe database throws an error
BNo rows are updated
COnly the first row is updated
DAll rows in the table are updated
✗ Incorrect
Without a WHERE clause, UPDATE affects every row in the table.
Which of these helps avoid accidental updates?
ARunning UPDATE without conditions
BDropping the table first
CUsing a WHERE clause
DUsing SELECT instead of UPDATE
✗ Incorrect
A WHERE clause limits which rows get updated, preventing accidental changes.
What is a safe practice before running an UPDATE?
AIgnoring errors
BBacking up data or using transactions
CUpdating all rows to NULL
DDeleting the table
✗ Incorrect
Backing up or using transactions lets you undo changes if needed.
What can happen if your WHERE clause is incorrect?
AMore rows than intended may be updated
BThe UPDATE will not run
COnly one row will update
DThe database will crash
✗ Incorrect
An incorrect WHERE clause can update unintended rows.
Why is UPDATE considered a risky operation?
ABecause it changes existing data permanently
BBecause it creates new tables
CBecause it only reads data
DBecause it deletes the database
✗ Incorrect
UPDATE modifies data permanently, so mistakes can cause data loss.
Explain why using UPDATE without a WHERE clause can be dangerous.
Think about what happens if no filter is applied.
You got /3 concepts.
Describe best practices to safely use the UPDATE statement.
Consider steps to avoid mistakes.
You got /3 concepts.
Practice
(1/5)
1. Why should you be careful when using the UPDATE statement without a WHERE clause?
easy
A. Because it will only update the first row.
B. Because it will delete the table.
C. Because it will create a new table.
D. Because it will update all rows in the table, possibly causing unwanted changes.
Solution
Step 1: Understand the role of WHERE in UPDATE
The WHERE clause limits which rows get updated. Without it, all rows are affected.
Step 2: Consider the effect of missing WHERE
Without WHERE, every row in the table changes, which can cause data loss or errors.
Final Answer:
Because it will update all rows in the table, possibly causing unwanted changes. -> Option D
Quick Check:
Missing WHERE updates all rows [OK]
Hint: Always use WHERE to limit rows in UPDATE [OK]
Common Mistakes:
Assuming UPDATE only changes one row by default
Forgetting WHERE clause causes full table update
Thinking UPDATE deletes data
2. Which of the following is the correct syntax to update the salary to 5000 for employees in department 10?
easy
A. UPDATE employees SET salary = 5000 department = 10;
B. UPDATE employees SET salary = 5000 WHERE department = 10;
C. UPDATE employees SET salary 5000 WHERE department = 10;
D. UPDATE employees salary = 5000 WHERE department = 10;
Solution
Step 1: Recall correct UPDATE syntax
The correct syntax is UPDATE table SET column = value WHERE condition;.
Step 2: Check each option
UPDATE employees SET salary = 5000 WHERE department = 10; matches the correct syntax exactly. Others miss keywords or punctuation.
Final Answer:
UPDATE employees SET salary = 5000 WHERE department = 10; -> Option B
Quick Check:
Correct UPDATE syntax uses SET and WHERE [OK]
Hint: UPDATE needs SET and WHERE for targeted changes [OK]
Common Mistakes:
Omitting SET keyword
Missing equal sign (=)
Leaving out WHERE clause
3. Given the table products with rows: {id:1, price:100}, {id:2, price:200}, {id:3, price:300} What will be the result after running: UPDATE products SET price = price + 50 WHERE id > 1; Then selecting all rows?
medium
A. [{id:1, price:150}, {id:2, price:250}, {id:3, price:350}]
B. [{id:1, price:150}, {id:2, price:200}, {id:3, price:300}]
C. [{id:1, price:100}, {id:2, price:250}, {id:3, price:350}]
D. [{id:1, price:100}, {id:2, price:200}, {id:3, price:300}]
Solution
Step 1: Identify rows affected by WHERE clause
The condition id > 1 affects rows with id 2 and 3 only.
Step 2: Calculate new prices for affected rows
Price for id 2: 200 + 50 = 250; Price for id 3: 300 + 50 = 350; id 1 remains 100.
Final Answer:
[{id:1, price:100}, {id:2, price:250}, {id:3, price:350}] -> Option C
Quick Check:
Only rows with id > 1 updated [OK]
Hint: Check WHERE condition carefully to know which rows update [OK]
Common Mistakes:
Updating all rows ignoring WHERE
Updating wrong rows by misreading condition
Changing values incorrectly
4. What is wrong with this SQL statement? UPDATE employees SET salary = salary + 1000 WHERE;
medium
A. The WHERE clause is incomplete and causes a syntax error.
B. The SET keyword is missing.
C. The table name is incorrect.
D. The salary column cannot be updated.
Solution
Step 1: Check the WHERE clause syntax
The WHERE clause must have a condition after it. Here it is empty, causing error.
Step 2: Verify other parts of the statement
SET keyword and table name are correct; salary can be updated.
Final Answer:
The WHERE clause is incomplete and causes a syntax error. -> Option A
Quick Check:
Incomplete WHERE causes syntax error [OK]
Hint: Always provide a condition after WHERE [OK]
Common Mistakes:
Leaving WHERE empty
Forgetting condition after WHERE
Assuming WHERE is optional but incomplete
5. You want to increase the price by 10% only for products priced below 100. Which UPDATE statement is safest to avoid changing other rows?
hard
A. UPDATE products SET price = price * 1.10 WHERE price < 100;
B. UPDATE products SET price = price * 1.10;
C. UPDATE products SET price = price + 10 WHERE price < 100;
D. UPDATE products SET price = price * 1.10 WHERE price > 100;
Solution
Step 1: Identify the condition to limit rows
Only products with price less than 100 should be updated, so WHERE price < 100 is needed.
Step 2: Choose correct price increase method
Increasing by 10% means multiplying price by 1.10, not adding 10.
Final Answer:
UPDATE products SET price = price * 1.10 WHERE price < 100; -> Option A
Quick Check:
Use WHERE and correct math for safe updates [OK]
Hint: Use WHERE to limit rows and correct math for updates [OK]
Common Mistakes:
Forgetting WHERE and updating all rows
Adding fixed amount instead of percentage
Using wrong condition in WHERE
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.