Knowledge is alive, so data must be corrected and sometimes deleted. In the Scriptorium scribes corrected scrolls - we do it with the
UPDATE and DELETE statements.UPDATE changes existing rows. After SET we give the new values, and WHERE points to which rows to correct:1UPDATE ksiazki SET cena = 19.99 WHERE id = 5;DELETE removes rows that meet a condition:1DELETE FROM ksiazki WHERE id = 7;This is the scribe's most important warning. If you forget the
WHERE clause:1UPDATE ksiazki SET cena = 0; -- changes the price of ALL books!
2DELETE FROM ksiazki; -- removes ALL books!Without
WHERE the statement affects the whole shelf. This is one of the most dangerous mistakes when working with a database. Before you run UPDATE or DELETE, make sure you have added a condition pointing to the right rows. Caution is the mark of a master!