Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1flyvH-0006Su-JX for pgsql-general@arkaria.postgresql.org; Sat, 04 Aug 2018 15:56:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1flyvD-0005rm-Mr for pgsql-general@arkaria.postgresql.org; Sat, 04 Aug 2018 15:56:51 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1flyvD-0005rf-3w for pgsql-general@lists.postgresql.org; Sat, 04 Aug 2018 15:56:51 +0000 Received: from p3plsmtpa12-03.prod.phx3.secureserver.net ([68.178.252.232]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1flyv9-0000dk-NZ for pgsql-general@lists.postgresql.org; Sat, 04 Aug 2018 15:56:49 +0000 Received: from [192.168.1.14] ([99.233.155.158]) by :SMTPAUTH: with ESMTPSA id lyv7fP3OvCNU2lyv7fmpnO; Sat, 04 Aug 2018 08:56:46 -0700 To: pgsql-general@lists.postgresql.org From: Simon White Organization: dCipher Computing Subject: Add column with If Not Exists Message-ID: <9bf027c0-ed29-852c-b5c0-49b166b792cf@dciphercomputing.com> Date: Sat, 4 Aug 2018 11:56:44 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-CA X-CMAE-Envelope: MS4wfNe3Q0pksNaCaYOmaMkt9Jo1EbaFX45BYo9Yd3pQHUOWJjx/Xk/odlz4zxzB1V61YO3fpr9iuw1x4Bs3dQ0+RhAAEJnHMFG+Kw0MDbL7cp6dCZOn9ng6 Ar5U/kQJQYI3oA0c78dosUGMFdz7thVapQ0Bu8ezRpMY30O/wyusXYETGB6lyaHbi/VkNtan6DZthNCGIDairwneibYgt5uqFFk= List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi I would like to suggest the addition of the "If not exists" to the Add Column feature of Postgres.  There are quite common situations where ensuring a column exists is important so that an update to remote devices will not fail but it is not so important that deprecated fields be removed.  This is often the case with backward compatibility.  New columns will not affect old systems but allows all remote devices running older software to be updated using the same process as new devices.  Once the hardware reaches end of life it will be replaced and the new hardware will use the new columns.  So having the ability to Alter the table with a series of Add Column commands ensures that the new records included in the update are added to the table.  Having the "if not exists" would remove all of this potential complexity and allows a quick and easy method to ensure the column exists in the table using simple SQL commands that will not cause errors if the column is already present. I understand that some people will feel this is not the recommended way to proceed.  I understand there are lots of ways this can be handled differently as I have been working with database of various kinds for over 30 years.  All I am suggesting is that this feature would be nice to have in some scenarios and thus would like it considered.  I do not wish to start a discussion on whether using it is a sound approach or not as that is a different discussion. -- Regards, Simon White dCipher Computing 705-500-0191