0
0
SQLquery~5 mins

UPDATE single column in SQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the SQL UPDATE statement do?
The UPDATE statement changes existing data in a table. It modifies one or more columns for rows that match a condition.
Click to reveal answer
beginner
How do you update a single column in SQL?
Use UPDATE table_name SET column_name = new_value WHERE condition; to change one column's value in rows that meet the 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 an example SQL query to update the salary column to 5000 for employees with id 3.
Example: <br>UPDATE employees SET salary = 5000 WHERE id = 3;
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
Which SQL keyword is used to change data in a table?
ASELECT
BUPDATE
CINSERT
DDELETE
What does the WHERE clause do in an UPDATE statement?
ASpecifies which rows to update
BSpecifies which columns to update
CCreates a new table
DDeletes rows
How do you update only the price column in a table named products?
AUPDATE products SET price = new_value;
BUPDATE products WHERE price = new_value;
CSELECT price FROM products;
DUPDATE products SET price = new_value WHERE condition;
What happens if you omit the WHERE clause in an UPDATE?
AAll rows are updated
BOnly one row is updated
CNo rows are updated
DThe query fails
Which of these is a valid SQL update statement for a single column?
AUPDATE table SET (column = value);
BUPDATE table WHERE id = 1 SET column = value;
CUPDATE table SET column = value WHERE id = 1;
DUPDATE table (column) VALUES (value);
Explain how to update a single column in a SQL table safely.
Think about how to change only certain rows without affecting the whole table.
You got /4 concepts.
    What could happen if you forget the WHERE clause in an UPDATE statement?
    Consider the impact on the entire table.
    You got /4 concepts.