pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Re: PRIMARY KEY and INDEX
3+ messages / 3 participants
[nested] [flat]

* Re: PRIMARY KEY and INDEX
@ 2004-09-02 13:50  Achilleus Mantzios <achill@matrix.gatewaynet.com>
  parent: Nosyman <nosyman@easymail.ro>
  1 sibling, 0 replies; 3+ messages in thread

From: Achilleus Mantzios @ 2004-09-02 13:50 UTC (permalink / raw)
  To: Nosyman <nosyman@easymail.ro>; +Cc: pgsql-sql

O kyrios Nosyman egrapse stis Sep 2, 2004 :

> It is necessary to define an index for a primary key column?
> 
> Let's have an example
> CREATE TABLE users(
> id_user INTEGER PRIMARY KEY,
> user_name VARCHAR(25)
> );
> 
> Does PgSQL automatically create an index for id_user (primary key) or it
> must be created by hand?

Yes a unique index is created automatically so as to enforce the 
PK constraint.

> 
> Thanks
> 
> 
> _________________________________________________________________
> Message
> sent using ITCNet free webmailer (http://www.easymail.ro)
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
> 

-- 
-Achilleus




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: PRIMARY KEY and INDEX
@ 2004-09-02 14:48  Devrim GUNDUZ <devrim@gunduz.org>
  parent: Nosyman <nosyman@easymail.ro>
  1 sibling, 0 replies; 3+ messages in thread

From: Devrim GUNDUZ @ 2004-09-02 14:48 UTC (permalink / raw)
  To: Nosyman <nosyman@easymail.ro>; +Cc: pgsql-sql

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Hi,

On Thu, 2 Sep 2004, Nosyman wrote:

> It is necessary to define an index for a primary key column?
>
> Let's have an example
> CREATE TABLE users(
> id_user INTEGER PRIMARY KEY,
> user_name VARCHAR(25)
> );
>
> Does PgSQL automatically create an index for id_user (primary key) or it
> must be created by hand?

You could give it a try before asking:

test=# CREATE TABLE users(
test(# id_user INTEGER PRIMARY KEY,
test(# user_name VARCHAR(25)
test(# );
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index 
"users_pkey" for table "users"
CREATE TABLE

Regards,
- --
Devrim GUNDUZ 
devrim~gunduz.org				devrim.gunduz~linux.org.tr
 			http://www.tdmsoft.com
 			http://www.gunduz.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFBNzLFtl86P3SPfQ4RAuOZAKDoE5NFtu7B3Dg356+CH5P9CGp7cgCfaBQm
33nie6C/x2PIfA0D1zqWgLE=
=QlUA
-----END PGP SIGNATURE-----



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* PRIMARY KEY and INDEX
@ 2004-09-02 16:58  Nosyman <nosyman@easymail.ro>
  0 siblings, 2 replies; 3+ messages in thread

From: Nosyman @ 2004-09-02 16:58 UTC (permalink / raw)
  To: pgsql-sql

It is necessary to define an index for a primary key column?

Let's have an example
CREATE TABLE users(
id_user INTEGER PRIMARY KEY,
user_name VARCHAR(25)
);

Does PgSQL automatically create an index for id_user (primary key) or it
must be created by hand?

Thanks


_________________________________________________________________
Message
sent using ITCNet free webmailer (http://www.easymail.ro)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2004-09-02 16:58 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-09-02 16:58 PRIMARY KEY and INDEX Nosyman <nosyman@easymail.ro>
2004-09-02 13:50 ` Achilleus Mantzios <achill@matrix.gatewaynet.com>
2004-09-02 14:48 ` Devrim GUNDUZ <devrim@gunduz.org>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox