From: | JORGE MALDONADO <jorgemal1960(at)gmail(dot)com> |
---|---|
To: | pgsql-novice <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: Restrictions for a specific situation in my DB |
Date: | 2020-05-13 14:10:03 |
Message-ID: | CAAY=A79H2-1vxGVbacnP7mex-WPzjoycEE-fNuGbMmi2w8tKLw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
*"You should always CC the list."*
I am sorry for that. I will take it into consideration from now on.
*"I have never heard of a "restriction" as a technical concept in
databases,so I cannot answer that."*
What I meant was "CONSTRAINT". I understand that, in PostgreSQL, I can
define "UNIQUE INDEX" and "UNIQUE CONSTRAINT" and that a "UNIQUE
CONSTRAINT" creates a "UNIQUE INDEX" behind the scenes.
So my question is:
Can a "UNIQUE CONSTRAINT" be used instead of a "UNIQUE INDEX"?
I searched the web for an answer and found that expressions like LEAST and
GREATEST are not allowed in a UNIQUE CONSTRAINT but they can be used in a
UNIQUE INDEX. I also tested directly in a table and I could verify it. So,
a UNIQUE INDEX is the choice to include LEAST and GREATEST.
With respect,
Jorge Maldonado
On Tue, May 12, 2020 at 10:46 PM Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
wrote:
> On Tue, 2020-05-12 at 18:27 -0500, JORGE MALDONADO wrote:
>
> You should always CC the list.
>
> > Does it has to be a UNIQUE INDEX?
>
> If you want to avoid duplicates, yes.
>
> > What about a RESTRICTION? I understand it also creates a UNIQUE INDEX
> behind the scenes.
> > Is a RESTRICTION not supported because of the LEAST and GREATEST
> expressions?
> > If it is, what is a reason to use a UNIQUE INDEX instead of a
> RESTRICTION?
> > I just want to fully understand the concept.
>
> I have never heard of a "restriction" as a technical concept in databases,
> so I cannot answer that.
>
> Yours,
> Laurenz Albe
> --
> +43-670-6056265
> Cybertec Schönig & Schönig GmbH
> Gröhrmühlgasse 26, A-2700 Wiener Neustadt
> Web: https://www.cybertec-postgresql.com
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Laurenz Albe | 2020-05-13 20:26:53 | Re: Restrictions for a specific situation in my DB |
Previous Message | Laurenz Albe | 2020-05-12 15:25:26 | Re: Restrictions for a specific situation in my DB |