Re: Unique primary index?

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: orange_crush_068(at)hotmail(dot)com
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Unique primary index?
Date: 2005-06-28 12:53:18
Message-ID: 20050628125318.GC20566@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Thu, Jun 23, 2005 at 05:43:52 -0700,
orange_crush_068(at)hotmail(dot)com wrote:
>
> What are the major differences between Unique, primary index & just
> plain index?
>
> When creating tables I nominate one of these, but not sure what the
> difference is?

A unique key has an implied constraint that no two nonnull values can
be the same. This is implemented using a unique index which is automatically
created.

A primary key is a unique key that has an implied not null constraint and
is the default for foreign key references into the table.

You can also create stand alone indexes for performance reasons or to
enforce a unique constraint on a subset of a table.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2005-06-28 14:31:46 Re: ERROR: "TZ"/"tz" not supported
Previous Message Bruno Wolff III 2005-06-28 12:47:33 Re: cross-table reference