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

From: Thom Brown <thom(at)linux(dot)com>
To: Stefan Keller <sfkeller(at)gmail(dot)com>
Cc: pgsql-general General <pgsql-general(at)postgresql(dot)org>
Subject: Re: No implicit index created when adding primary key with ALTER TABLE
Date: 2011-06-14 07:49:20
Message-ID: BANLkTinzK2WRu6Ys1FVvH2t5Y8cYuW3WaQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 14 June 2011 06:39, Stefan Keller <sfkeller(at)gmail(dot)com> wrote:
> Hi
>
> I observed some strange behaviour when adding a primary key with ALTER TABLE:
>
> Given CREATE TABLE mytable1 (id serial, name text);
> I filled it with data then did a
>  CREATE TABLE mytable2 AS SELECT * FROM mytable1;
>  ALTER TABLE mytable2 ADD PRIMARY KEY(id);
>
> The last command reports - as usual - that implicitly an index on id
> ("mytable_pkey") was created - but it did not! It adds only a primary
> key constraint on id. Can anybody explain this?
>
> Yours, S.
>
> P.S. I have installed "PostgreSQL 9.1alpha1, compiled by Visual C++
> build 1500, 32-bit".

Shouldn't you be looking for mytable2_pkey?

--
Thom Brown
Twitter: @darkixion
IRC (freenode): dark_ixion
Registered Linux user: #516935

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Karsten Hilbert 2011-06-14 07:52:04 Re: determine client os
Previous Message Sim Zacks 2011-06-14 07:39:11 thoughts on interactive query