Updating & Deleting Data Flashcards

All 4 cards in this deck

Which SQL command changes data in records that already exist?

UPDATE, with SET giving the new values and WHERE choosing the records:
UPDATE Pet SET Weight = 4.2 WHERE PetID = 7

Which SQL command removes records from a table?

DELETE FROM, with WHERE choosing the records to remove:
DELETE FROM Pet WHERE PetID = 7

What happens if an SQL UPDATE or DELETE command has no WHERE clause?

It acts on every record in the table: every record is changed, or every record is deleted.

In SQL UPDATE and DELETE commands, why is the primary key often used in the WHERE clause?

Its value is unique, so the condition picks out exactly one record. A condition on a non-unique field, such as a name, could change or delete other records too.