sql-update Flashcards

1
Q

How do you update rows in a database table?

A

Using the “update” keyword along with the name of the table in double quotes, followed by the “set” keyword on the next line with the new value in single quotes, followed by the “where” clause on the next line in order to specify which row to update.

update (name of table in double quotes)
set (name of column in double quotes) = (name of new value in single quotes)
where (name of column in double quotes) = (name of old value in single quotes)
returning *;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Why is it important to include a “where” clause in your update statements?

A

Because if the “where” clause is omitted, the update will apply to the whole table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly