Re: Key Vs Index

From: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
To: Abdul Rahman <abr_ora(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Key Vs Index
Date: 2009-02-11 07:32:04
Message-ID: dcc563d10902102332oaf329e6i50b63e693e2d5b0d@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Feb 11, 2009 at 12:09 AM, Abdul Rahman <abr_ora(at)yahoo(dot)com> wrote:
> In Oracle, the index is automatically created during the creation of Primary
> Key. But in PostgreSQL either index is implicitly created of the user hast
> create it explicitly. I don't find any index against Primary Key and have to
> create index on this key.

Let's look:
smarlowe=# create table test (id int primary key, info text);
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"test_pkey" for table "test"
CREATE TABLE
smarlowe=# \d test
Table "public.test"
Column | Type | Modifiers
--------+---------+-----------
id | integer | not null
info | text |
Indexes:
"test_pkey" PRIMARY KEY, btree (id)

See where it says btree(id) under Indexes:? That's telling you it's
got an index.

Note that the index on the FK side isn't auto created.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Abdul Rahman 2009-02-11 07:37:26 Re: Key Vs Index
Previous Message Craig Ringer 2009-02-11 07:31:52 Re: Key Vs Index