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 1oDWeC-0002Yl-IU for pgsql-docs@arkaria.postgresql.org; Mon, 18 Jul 2022 19:43:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oDWeB-00012T-01 for pgsql-docs@arkaria.postgresql.org; Mon, 18 Jul 2022 19:43:15 +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 1oDWeA-00012K-Oj for pgsql-docs@lists.postgresql.org; Mon, 18 Jul 2022 19:43:14 +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 1oDWe3-0008VQ-Vk for pgsql-docs@lists.postgresql.org; Mon, 18 Jul 2022 19:43:14 +0000 Received: from bruce by momjian.us with local (Exim 4.94.2) (envelope-from ) id 1oDWdz-005jKi-1V; Mon, 18 Jul 2022 15:43:03 -0400 Date: Mon, 18 Jul 2022 15:43:03 -0400 From: Bruce Momjian To: "David G. Johnston" Cc: frank_limpert@yahoo.com, Pg Docs Subject: Re: CREATE TABLE AS, section IF NOT EXISTS should clarify what happens to the data Message-ID: References: <164441177106.9677.5991676148704507229@wrigleys.postgresql.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="2SFIwF3H5IA4Nk+X" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --2SFIwF3H5IA4Nk+X Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit fOn Thu, Jul 14, 2022 at 06:47:19PM -0700, David G. Johnston wrote: > Not only is the existing table not modified, I think that the select query > portion of the command is never even executed.  That would seem to be useful > knowledge to have. > > Maybe something like: > > >  Do not throw an error if a relation with the same name already exists. >  A notice is issued in this case. >  If WITH DATA is specified (the default) the execution of > the parsed query does not happen, leaving the existing table with its existing > contents. > I tried to go in that direction, but couldn't clearly name the SELECT/VALUES part of the CREATE TABLE AS query because CREATE TABLE AS is also a query. I felt trying to say we ran the CREATE TABLE AS query but not the SELECT/VALUES of the query was just too confusing. I used "simply issue a notice" as implying that nothing else happens, which I considered sufficient. > > I've removed the xref to create table as there is nothing additional there of > material benefit - the sentence: Okay, removed. Updated patch attached. -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com Indecision is a decision. Inaction is an action. Mark Batterson --2SFIwF3H5IA4Nk+X Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="exists.diff" diff --git a/doc/src/sgml/ref/create_table_as.sgml b/doc/src/sgml/ref/create_table_as.sgml index 07558ab56c..8429333e3a 100644 --- a/doc/src/sgml/ref/create_table_as.sgml +++ b/doc/src/sgml/ref/create_table_as.sgml @@ -100,9 +100,8 @@ CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE [ IF NOT EXI IF NOT EXISTS - Do not throw an error if a relation with the same name already exists. - A notice is issued in this case. Refer to - for details. + Do not throw an error if a relation with the same name already + exists; simply issue a notice and leave the table unmodified. --2SFIwF3H5IA4Nk+X--