From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Simon White <simonwhite@dciphercomputing.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Add column with If Not Exists
Date: Sat, 4 Aug 2018 10:41:11 -0700
Message-ID: <b01c5a81-8bb5-674a-a877-dfd1512edddf@aklaver.com> (raw)
In-Reply-To: <9bf027c0-ed29-852c-b5c0-49b166b792cf@dciphercomputing.com>
References: <9bf027c0-ed29-852c-b5c0-49b166b792cf@dciphercomputing.com>
On 08/04/2018 08:56 AM, Simon White wrote:
> 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.
Sort of like this:
https://www.postgresql.org/docs/9.6/static/sql-altertable.html
"ADD [ COLUMN ] [ IF NOT EXISTS ] ..."
in 9.6+
>
> 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.
>
--
Adrian Klaver
adrian.klaver@aklaver.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: adrian.klaver@aklaver.com, simonwhite@dciphercomputing.com
Subject: Re: Add column with If Not Exists
In-Reply-To: <b01c5a81-8bb5-674a-a877-dfd1512edddf@aklaver.com>
References: <9bf027c0-ed29-852c-b5c0-49b166b792cf@dciphercomputing.com> <b01c5a81-8bb5-674a-a877-dfd1512edddf@aklaver.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox