agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: lucazeo@gmail.com <lucazeo@gmail.com>
To: pgsql-sql@postgresql.org
Subject: Re: Unique index VS unique constraint
Date: Fri, 04 Oct 2013 19:41:17 +0200
Message-ID: <524EFDBD.9010204@gmail.com> (raw)
In-Reply-To: <CAAY=A78oJ--0aPm4E6ASJ32Z3UHk0nOqHQ_SvrtjOmq7i=UKDQ@mail.gmail.com>
References: <CAAY=A78oJ--0aPm4E6ASJ32Z3UHk0nOqHQ_SvrtjOmq7i=UKDQ@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>

Il 04/10/2013 18:48, JORGE MALDONADO ha scritto:
> I have search for information about the difference between "unique 
> index" and "unique constraint" in PostgreSQL without getting to a 
> specific answer, so I kindly ask for an explanation that helps me 
> clarify such concept.

2 main differences.

First is the meaning: primary key identifies a record. A unique just 
tells you that that value of the record, in the table is unique. If you 
use keys, db structure will be more intelligible (my opinion).

Second one is functional: in an unique constraint you can allow NULL 
values and ignore them. A primary key does not allow this.

> Respectfully,
> Jorge Maldonado

Regards,

Luca.


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



view thread (9+ messages)  latest in thread

Message-ID: <524EFDBD.9010204@gmail.com>
Permalink:  ../524EFDBD.9010204@gmail.com/
Also on:    postgresql.org/message-id/524EFDBD.9010204@gmail.com

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: lucazeo@gmail.com
  Subject: Re: Unique index VS unique constraint
  In-Reply-To: <524EFDBD.9010204@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox