Re: Why isn't there a IF NOT EXISTS clause on constraint creation? - Mailing list pgsql-admin

From Geoff Winkless
Subject Re: Why isn't there a IF NOT EXISTS clause on constraint creation?
Date
Msg-id CAEzk6fdhg0NSCbs4GPdwYz33EKCN-+UFuS_f2AbN9cW4SG2oNg@mail.gmail.com
Whole thread Raw
In response to Re: Why isn't there a IF NOT EXISTS clause on constraint creation?  (richard coleman <rcoleman.ascentgl@gmail.com>)
List pgsql-admin
On Thu, 31 Aug 2023 at 14:00, richard coleman
<rcoleman.ascentgl@gmail.com> wrote:
> Thanks, but a CREATE OR REPLACE is functionally equivalent to a DROP IF NOT EXISTS; ALTER TABLE pairing.
> In both cases you would be recreating an identical constraint to the one that exists if it was already there.  If you
havelarge tables, and/or a composite key, that's a non-trivial amount of time and resources wasted.
 

It absolutely does not have to be. CREATE OR REPLACE should be smart
enough to do nothing if the existing object were the same as the new
one.

Geoff



pgsql-admin by date:

Previous
From: richard coleman
Date:
Subject: Re: Why isn't there a IF NOT EXISTS clause on constraint creation?
Next
From: Daulat
Date:
Subject: DBLINK Error