Re: No implicit index created when adding primary key with ALTER TABLE

From: Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Cc: Stefan Keller <sfkeller(at)gmail(dot)com>, Thom Brown <thom(at)linux(dot)com>
Subject: Re: No implicit index created when adding primary key with ALTER TABLE
Date: 2011-06-14 22:48:14
Message-ID: 201106141548.15513.adrian.klaver@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tuesday, June 14, 2011 3:31:12 pm Stefan Keller wrote:
> Hi Thom
>
> 2011/6/14 Thom Brown <thom(at)linux(dot)com>:
> > Shouldn't you be looking for mytable2_pkey?
>
> Yes; but that was my typo. I tried it several times on two tables.
> My explanation is that the message (saying that an index was
> implicitly created) is simply wrong.

Works here:

test(5432)aklaver=>SELECT version();
version
--------------------------------------------------------------------------------------------------
PostgreSQL 9.0.3 on i686-pc-linux-gnu, compiled by GCC gcc (Ubuntu
4.4.3-4ubuntu5) 4.4.3, 32-bit
(1 row)

test(5432)aklaver=> ALTER TABLE mytable2 ADD PRIMARY KEY(id);
NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index
"mytable2_pkey" for table "mytable2"
ALTER TABLE
test(5432)aklaver=>\d+ mytable2
Table "public.mytable2"
Column | Type | Modifiers | Storage | Description
--------+---------+-----------+----------+-------------
id | integer | not null | plain |
name | text | | extended |
Indexes:
"mytable2_pkey" PRIMARY KEY, btree (id)
Has OIDs: no

Note the btree designation.

>
> Yours, S.

--
Adrian Klaver
adrian(dot)klaver(at)gmail(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Craig Ringer 2011-06-14 23:50:10 Re: random backend crashes - how to debug ( Is crash dump handler released ? )
Previous Message Tom Lane 2011-06-14 22:39:43 Re: No implicit index created when adding primary key with ALTER TABLE