Section I - 2.9: Use SELECT to confirm set of rows before DELETE

From: PG Doc comments form <noreply(at)postgresql(dot)org>
To: pgsql-docs(at)lists(dot)postgresql(dot)org
Cc: adrian(dot)nesse(dot)wiik(at)gmail(dot)com
Subject: Section I - 2.9: Use SELECT to confirm set of rows before DELETE
Date: 2022-06-06 21:19:17
Message-ID: 165455035739.573549.17628498892386696027@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/14/tutorial-delete.html
Description:

Since this tutorial section is coined at beginners, I think it could be
useful to tip users about the possibility to use a SELECT statement with the
exact same qualification(s) as the DELETE statement they're planning to run
to see which rows are about to be deleted, to avoid unintended deletion of
rows. I suggest something like this:

...
Without a qualification, DELETE will remove all rows from the given table,
leaving it empty. The system will not request confirmation before doing
this!

You can check which rows will be deleted by any DELETE statement on the
form:
```DELETE FROM tablename ... <qualificaton> ...```
by rewriting it into a corresponding SELECT statement:
```SELECT * FROM tablename ... <qualification> ...```

This is my first attempt at contributing to the community, so please be
nice. :)

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message PG Doc comments form 2022-06-06 22:11:54 Unclear Wording
Previous Message Shay Rojansky 2022-06-05 08:59:29 Re: Lower/upper-case consistency with function names