Re: Are Indices automatically generated for primary keys?

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

 



Clemens Eisserer <linuxhippy@xxxxxxxxx> wrote:
 
> Are indices for columns marked with "PRIMARY KEY" automatically
> generated by postgresql, or do I have to do it manually?
 
If you look at the documentation page for CREATE TABLE, you'll see
the following:
 
| PostgreSQL automatically creates an index for each unique
| constraint and primary key constraint to enforce uniqueness. Thus,
| it is not necessary to create an index explicitly for primary key
| columns. (See CREATE INDEX for more information.)
 
http://www.postgresql.org/docs/current/interactive/sql-createtable.html
 
There's a lot of information on the page, but if you use your
browser to search for PRIMARY KEY within the page, it's not too hard
to find.
 
Also, if you create a primary key or a unique constraint on a table,
you should see a notice informing you of the creation of the index,
and its name.
 
-Kevin

-- 
Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance


[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux