Re: Restrictions for a specific situation in my DB

Поиск
Список
Период
Сортировка
От Laurenz Albe
Тема Re: Restrictions for a specific situation in my DB
Дата
Msg-id 9a0d712598b38a190c81da043b5e9620d54a96b3.camel@cybertec.at
обсуждение исходный текст
Ответ на Re: Restrictions for a specific situation in my DB  (JORGE MALDONADO <jorgemal1960@gmail.com>)
Список pgsql-novice
On Wed, 2020-05-13 at 09:10 -0500, JORGE MALDONADO wrote:
> 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.

You got it.
A unique constraint can only be defined on columns, not on expressions.
But unique indexes can have an expression as key.

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com




В списке pgsql-novice по дате отправления:

Предыдущее
От: JORGE MALDONADO
Дата:
Сообщение: Re: Restrictions for a specific situation in my DB
Следующее
От: Nam Nguyen
Дата:
Сообщение: connect to postgresql Server via two gateway Traffic Server instancesusing explicit proxying