Re: PRIMARY KEY and indexes

From: "Sean Davis" <sdavis2(at)mail(dot)nih(dot)gov>
To: "Craig Bryden" <postgresql(at)bryden(dot)co(dot)za>, "pgsql" <pgsql-general(at)postgresql(dot)org>
Subject: Re: PRIMARY KEY and indexes
Date: 2005-04-23 12:21:33
Message-ID: 001101c547fe$fc7d9100$5179f345@WATSON
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


----- Original Message -----
From: "Craig Bryden" <postgresql(at)bryden(dot)co(dot)za>
To: "pgsql" <pgsql-general(at)postgresql(dot)org>
Sent: Saturday, April 23, 2005 5:45 AM
Subject: [GENERAL] PRIMARY KEY and indexes

> Hi
>
> I come from a MS-SQL background and I'm trying to get some clarity on
> indexes in Postgres. If anyone can help with the following questions it
> would be much appreciated:
>
> 1. When creating a primary key contraint on a table, is an equivalent
> index
> automatically created for you, or would I have to create an index
> manually?

I think if you try it:

CREATE TABLE pk_idx_test (
id INT PRIMARY KEY
);

You will get:

NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"pk_idx_test_pkey" for table "pk_idx_test"

Query returned successfully with no result in 266 ms.

> 2. How do I create a clustered index in postgres?

See the manual here:
http://www.postgresql.org/docs/8.0/interactive/index.html
and specifically here:
http://www.postgresql.org/docs/8.0/interactive/sql-cluster.html
http://www.postgresql.org/docs/8.0/interactive/sql-altertable.html

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Brian Maguire 2005-04-23 14:41:00 Pgpool questions
Previous Message Typing80wpm 2005-04-23 11:45:58 Intuitive Software and Mario Brothers