Updating & Deleting Data Flashcards
All 4 cards in this deck
Which SQL command changes data in records that already exist?
UPDATE, withSETgiving the new values andWHEREchoosing the records:UPDATE Pet SET Weight = 4.2 WHERE PetID = 7Which SQL command removes records from a table?
DELETE FROM, withWHEREchoosing the records to remove:DELETE FROM Pet WHERE PetID = 7What happens if an SQL
UPDATEorDELETEcommand has noWHEREclause?It acts on every record in the table: every record is changed, or every record is deleted.
In SQL
UPDATEandDELETEcommands, why is the primary key often used in theWHEREclause?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.