We use cookies to enhance your experience on the site
CodeWorlds

The scribe's safe habits

You now hold all three great commands. Before you move on, let us cement the discipline that ensures you never destroy the Library through carelessness.

The golden rule: WHERE first

I will repeat it one last time, for it is the most important sentence of this location: UPDATE and DELETE without WHERE act on the whole shelf. Build the habit of writing the

WHERE
condition before you write the rest of the command.

Check before you run

An experienced scribe never shoots in the dark. First they check which rows will be affected, by turning the

UPDATE
/
DELETE
into a
SELECT
with the same
WHERE
:

1SELECT * FROM ksiazki WHERE dostepna = 0;

If this

SELECT
returns exactly the scrolls you want to remove - only then do you run:

1DELETE FROM ksiazki WHERE dostepna = 0;

Three steps of safe editing

  1. Write the
    WHERE
    condition
    - define exactly which rows you want to change.
  2. Check it with a
    SELECT
    - see how many and which rows match.
  3. Run the
    UPDATE
    or
    DELETE
    with the same
    WHERE
    .

Small steps, great care

Modify data in small portions. It is better to run several precise commands than one big one that covers too much. And if an operation is truly serious - a good scribe first makes a copy of the important scrolls. Remember: in the Library there is no trash bin and no undo.

Go to CodeWorlds