Re: Why isn't there a IF NOT EXISTS clause on constraint creation?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



richard coleman <rcoleman.ascentgl@xxxxxxxxx> writes:
> Why doesn't ALTER TABLE ...  ADD CONSTRAINT not come with an ALTER TABLE
> ... ADD CONSTRAINT IF NOT EXISTS variant?

There's a general allergy in this project to CREATE IF NOT EXISTS,
because it's a foot-gun.  If the command succeeds, you know that
an object (constraint or whatever) by that name exists, but you
have no right to assume anything whatsoever about its properties.

CREATE OR REPLACE semantics are a lot less squishy.  Would a
command of that form solve your problem?  (I'm not sure about
a pleasing way to write that within ALTER TABLE, but this gripe
is about semantics not syntax.)

			regards, tom lane





[Index of Archives]     [Postgresql Home]     [Postgresql General]     [Postgresql Performance]     [Postgresql PHP]     [Postgresql Jobs]     [PHP Users]     [PHP Databases]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Forum]

  Powered by Linux