Re: Unique index VS unique constraint - Mailing list pgsql-sql

From Sergey Konoplev
Subject Re: Unique index VS unique constraint
Date
Msg-id CAL_0b1uAZLLLipu0_RhcqrsAE1WkBJVYHHOfHuP1VcZVMzKAtg@mail.gmail.com
Whole thread Raw
In response to Re: Unique index VS unique constraint  (JORGE MALDONADO <jorgemal1960@gmail.com>)
List pgsql-sql
On Sat, Oct 5, 2013 at 3:24 PM, JORGE MALDONADO <jorgemal1960@gmail.com> wrote:
> So, let´s say that I have the following simple example table:
>
> 1. cus_id
> 2. cus_name
> 3. Other fields . . .
>
> Where "cus_id" is the primary key. And let´s also say that I want "cus_name"
> to be unique. I have the option to create a unique constraint or a unique
> index. What would be the best decision and why?

Unique constraint would be the right choice, because you want to
constrain the values in the column of your table. The unique index is
just a tool the constrain uses to perform its function. This index
will be created automatically when you add the constraint.

--
Kind regards,
Sergey Konoplev
PostgreSQL Consultant and DBA

http://www.linkedin.com/in/grayhemp
+1 (415) 867-9984, +7 (901) 903-0499, +7 (988) 888-1979
gray.ru@gmail.com



pgsql-sql by date:

Previous
From: JORGE MALDONADO
Date:
Subject: Re: Unique index VS unique constraint
Next
From: Kaleeswaran Velu
Date:
Subject: ...