Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oALZt-000402-MP for pgsql-docs@arkaria.postgresql.org; Sun, 10 Jul 2022 01:17:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oALZs-0003Bg-Ft for pgsql-docs@arkaria.postgresql.org; Sun, 10 Jul 2022 01:17:40 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oALZs-00039T-8r for pgsql-docs@lists.postgresql.org; Sun, 10 Jul 2022 01:17:40 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oALZp-000533-Q3 for pgsql-docs@lists.postgresql.org; Sun, 10 Jul 2022 01:17:39 +0000 Received: from bruce by momjian.us with local (Exim 4.94.2) (envelope-from ) id 1oALZn-0019YI-W6; Sat, 09 Jul 2022 21:17:35 -0400 Date: Sat, 9 Jul 2022 21:17:35 -0400 From: Bruce Momjian To: adrian.nesse.wiik@gmail.com, pgsql-docs@lists.postgresql.org Subject: Re: Section I - 2.9: Use SELECT to confirm set of rows before DELETE Message-ID: References: <165455035739.573549.17628498892386696027@wrigleys.postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <165455035739.573549.17628498892386696027@wrigleys.postgresql.org> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Jun 6, 2022 at 09:19:17PM +0000, PG Doc comments form wrote: > 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 ... ...``` > by rewriting it into a corresponding SELECT statement: > ```SELECT * FROM tablename ... ...``` > > This is my first attempt at contributing to the community, so please be > nice. :) Uh, this is more of a general SQL training that we don't normally cover in the Postgres docs --- we try to focus on Postgres-specific stuff that people need to know. -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com Indecision is a decision. Inaction is an action. Mark Batterson