Thread: ADD OR ALTER column
I'm probably missing something, but can anyone see a reason why adding an ADD OR ALTER COLUMN syntax to the ALTER TABLE command isn't either a) achievable or b) desirable?
It seems to me to be eminently useful and not overly difficult, while potentially saving a significant amount of effort on the part of users.
Geoff
>I'm probably missing something, but can anyone see a reason why adding an ADD OR >ALTER COLUMN syntax to the ALTER TABLEcommand isn't either a) achievable or b) >desirable? >It seems to me to be eminently useful and not overly difficult, while potentially >saving a significant amount of efforton the part of users. what is your use case ? Not sure what benefit you are talking about. thanks.
På fredag 12. januar 2018 kl. 14:45:07, skrev Geoff Winkless <pgsqladmin@geoff.dj>:
I'm probably missing something, but can anyone see a reason why adding an ADD OR ALTER COLUMN syntax to the ALTER TABLE command isn't either a) achievable or b) desirable?It seems to me to be eminently useful and not overly difficult, while potentially saving a significant amount of effort on the part of users.Geoff
What about using
ALTER TABLE tab ADD COLUMN IF NOT EXISTS mycol mytype;
I don't think there's an ALTER COLUMN IF EXISTS tho...
--
Andreas Joseph Krogh
CTO / Partner - Visena AS
Mobile: +47 909 56 963
Attachment
>I'm probably missing something, but can anyone see a reason why adding an ADD OR >ALTER COLUMN syntax to the ALTER TABLE command isn't either a) achievable or b) >desirable?
>It seems to me to be eminently useful and not overly difficult, while potentially >saving a significant amount of effort on the part of users.
what is your use case ? Not sure what benefit you are talking about.
Having one script to ensure the user has the latest version of a db, without a significant amount of to-and-fro effort.
Actually I would probably rather have CREATE OR ALTER TABLE instead, with the syntax of CREATE TABLE but with an optional USING clause for each column for use if the column already existed and was of a non-implicitly-castable type, along with an optional WITH DROP COLUMNS [ * | name [,...] ] clause (to allow user to drop any (or specific) columns not in the new definition).
That's likely to be rather more effort though, at first glance.
Geoff