Consider a table Employees with columns id, name, and salary. Initially, the table has these rows:
id | name | salary ---+---------+-------- 1 | Alice | 5000 2 | Bob | 6000 3 | Charlie | 7000
What will be the salaries of all employees after running this query?
UPDATE Employees SET salary = 10000;
UPDATE Employees SET salary = 10000;
Think about what happens if you don't specify a WHERE clause in an UPDATE statement.
Without a WHERE clause, the UPDATE affects all rows in the table. So every employee's salary is set to 10000.
Which of the following best explains the danger of running an UPDATE statement without a WHERE clause?
Think about what happens when no filter is applied to an update.
Without a WHERE clause, the UPDATE affects every row, which can overwrite data unintentionally and cause data loss.
Given the Employees table, select the correct UPDATE statement that changes only Bob's salary to 8000.
Remember the correct order of clauses in an UPDATE statement.
The correct syntax is UPDATE table SET column = value WHERE condition;. Option D follows this correctly and targets only Bob.
Consider an empty table Products with columns id and price. What is the result of running:
UPDATE Products SET price = 10;
What will be the state of the table after this query?
Think about how UPDATE affects rows when there are none.
If the table has no rows, UPDATE affects zero rows. The table remains empty.
A developer ran this query:
UPDATE Orders SET status = 'shipped';
They intended to update only orders with id > 100. What happened and why?
Recall what happens when UPDATE is run without a filter.
Without a WHERE clause, the UPDATE affects every row, causing unintended data changes and data loss.