Search Postgresql Archives

Re: Is the primary key constraint also an index?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 13/08/2008 03:18, Tim Uckun wrote:
If I have a primary key constraint defined in the database do I also
need to create an index on that field for fast lookup?

As I understand it, creating a primary key on a table also creates an index automatically:

testdb=# create table test(f1 integer, f2 text);
CREATE TABLE
testdb=# alter table test add constraint test_pk primary key(f1);
NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index test_pk" for table "test"
ALTER TABLE


Ray.

------------------------------------------------------------------
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
rod@xxxxxx
Galway Cathedral Recitals: http://www.galwaycathedral.org/recitals
------------------------------------------------------------------


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux