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

From: Geoff Winkless <pgsqladmin(at)geoff(dot)dj>
To: richard coleman <rcoleman(dot)ascentgl(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Pgsql-admin <pgsql-admin(at)lists(dot)postgresql(dot)org>
Subject: Re: Why isn't there a IF NOT EXISTS clause on constraint creation?
Date: 2023-09-01 13:14:06
Message-ID: CAEzk6fdhg0NSCbs4GPdwYz33EKCN-+UFuS_f2AbN9cW4SG2oNg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Thu, 31 Aug 2023 at 14:00, richard coleman
<rcoleman(dot)ascentgl(at)gmail(dot)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 have large 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

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Daulat 2023-09-02 07:50:50 DBLINK Error
Previous Message richard coleman 2023-09-01 12:58:00 Re: Why isn't there a IF NOT EXISTS clause on constraint creation?