pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
primary keys
10+ messages / 9 participants
[nested] [flat]

* primary keys
@ 1998-05-18 07:48  Perry Seleski <seleski@ronix.ptf.hro.nl>
  0 siblings, 1 reply; 10+ messages in thread

From: Perry Seleski @ 1998-05-18 07:48 UTC (permalink / raw)
  To: pgsql-sql

I would really like to know how I can define a primary key in postgres.
The database is for a search engine. The table looks like this:

CREATE TABLE Homepages (
	URL			varchar(80),
	PageName		varchar(80),
	UserName		varchar(40),
	Keywords		varchar(255)
);

And I'd like to define the attibute URL as the primary key but I've
got no clue on how to do that. Anyone?

Thanks in advance,

Perry Seleski
Rotterdam Art Institute



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

* Re: [SQL] primary keys
@ 1998-05-18 12:29  Marin D <marin@iclub.techno-link.com>
  parent: Perry Seleski <seleski@ronix.ptf.hro.nl>
  0 siblings, 0 replies; 10+ messages in thread

From: Marin D @ 1998-05-18 12:29 UTC (permalink / raw)
  To: Perry Seleski <seleski@ronix.ptf.hro.nl>; +Cc: pgsql-sql


Just use the ANSI SQL syntax


On Mon, 18 May 1998, Perry Seleski wrote:

> 
> CREATE TABLE Homepages (
> 	URL			varchar(80) PRIMARY KEY,
> 

	
Marin




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

* primary keys
@ 2002-11-06 14:18  Huub <v.niekerk@freeler.nl>
  0 siblings, 5 replies; 10+ messages in thread

From: Huub @ 2002-11-06 14:18 UTC (permalink / raw)
  To: pgsql-sql

Hi,

I want to create a table which has 2 columns, and both columns have to 
be primary key (or: together they are the primary key). How can I do 
this using SQL? Using pgAdminII for Postgres7.2.2 on RH8.

Thanks

Huub




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

* Re: primary keys
@ 2002-11-07 13:54  terry@greatgulfhomes.com
  parent: Huub <v.niekerk@freeler.nl>
  4 siblings, 2 replies; 10+ messages in thread

From: terry@greatgulfhomes.com @ 2002-11-07 13:54 UTC (permalink / raw)
  To: 'Huub' <v.niekerk@freeler.nl>; pgsql-sql

A table can only have ONE primary key.  It can have additional indexes with
a UNIQUE restriction, thereby forcing the second field to be as good as a
primary key.

That is probably what you are looking for, however, you can also in PG Admin
II select multiple fields as being the member of the primary key.


Terry Fielder
Network Engineer
Great Gulf Homes / Ashton Woods Homes
terry@greatgulfhomes.com



> -----Original Message-----
> From: pgsql-sql-owner@postgresql.org
> [mailto:pgsql-sql-owner@postgresql.org]On Behalf Of Huub
> Sent: Wednesday, November 06, 2002 9:19 AM
> To: pgsql-sql@postgresql.org
> Subject: [SQL] primary keys
>
>
> Hi,
>
> I want to create a table which has 2 columns, and both
> columns have to
> be primary key (or: together they are the primary key). How can I do
> this using SQL? Using pgAdminII for Postgres7.2.2 on RH8.
>
> Thanks
>
> Huub
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>




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

* Re: primary keys
@ 2002-11-07 14:01  Rachel.Vaudron <rachel@lazaret.unice.fr>
  parent: Huub <v.niekerk@freeler.nl>
  4 siblings, 0 replies; 10+ messages in thread

From: Rachel.Vaudron @ 2002-11-07 14:01 UTC (permalink / raw)
  To: Huub <v.niekerk@freeler.nl>; +Cc: pgsql-sql

Hi,

For example you can do something like that:

CREATE TABLE "try" (
        "field1"        TEXT NOT NULL,
        "field2"        INT4 NOT NULL,
	"field3"	TEXT, PRIMARY KEY (field1, field2));

**************************************
   Rachel.Vaudron@lazaret.unice.fr
Laboratoire de prehistoire du Lazaret
 33 bis bd Franck Pilatte 06300 Nice
tel:04-92-00-17-37/fax:04-92-00-17-39
******** Windows a bug's life ********

On Wed, 6 Nov 2002, Huub wrote:

> Hi,
>
> I want to create a table which has 2 columns, and both columns have to
> be primary key (or: together they are the primary key). How can I do
> this using SQL? Using pgAdminII for Postgres7.2.2 on RH8.
>
> Thanks
>
> Huub
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>




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

* Re: primary keys
@ 2002-11-07 14:28  Achilleus Mantzios <achill@matrix.gatewaynet.com>
  parent: Huub <v.niekerk@freeler.nl>
  4 siblings, 0 replies; 10+ messages in thread

From: Achilleus Mantzios @ 2002-11-07 14:28 UTC (permalink / raw)
  To: Huub <v.niekerk@freeler.nl>; +Cc: pgsql-sql

On Wed, 6 Nov 2002, Huub wrote:

> Hi,
>
> I want to create a table which has 2 columns, and both columns have to
> be primary key (or: together they are the primary key). How can I do
> this using SQL? Using pgAdminII for Postgres7.2.2 on RH8.

I dont know the way in pgAdminII, but from psql simply give:

CREATE TABLE foo(
name varchar(20) NOT NULL,
id int4 NOT NULL,
PRIMARY KEY (name,id));

>
> Thanks
>
> Huub
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>

==================================================================
Achilleus Mantzios
S/W Engineer
IT dept
Dynacom Tankers Mngmt
Nikis 4, Glyfada
Athens 16610
Greece
tel:    +30-10-8981112
fax:    +30-10-8981877
email:  achill@matrix.gatewaynet.com
        mantzios@softlab.ece.ntua.gr




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

* Re: primary keys
@ 2002-11-07 14:29  Huub <v.niekerk@freeler.nl>
  parent: terry@greatgulfhomes.com
  1 sibling, 0 replies; 10+ messages in thread

From: Huub @ 2002-11-07 14:29 UTC (permalink / raw)
  To: pgsql-sql

terry@greatgulfhomes.com wrote:

> A table can only have ONE primary key.  It can have additional indexes 
> with
> a UNIQUE restriction, thereby forcing the second field to be as good as a
> primary key.
>
> That is probably what you are looking for, however, you can also in PG 
> Admin
> II select multiple fields as being the member of the primary key.
>
>
> Terry Fielder
> Network Engineer
> Great Gulf Homes / Ashton Woods Homes
> terry@greatgulfhomes.com
>
>
>
>
> >-----Original Message-----
> >From: pgsql-sql-owner@postgresql.org
> >[mailto:pgsql-sql-owner@postgresql.org]On Behalf Of Huub
> >Sent: Wednesday, November 06, 2002 9:19 AM
> >To: pgsql-sql@postgresql.org
> >Subject: [SQL] primary keys
> >
> >
> >Hi,
> >
> >I want to create a table which has 2 columns, and both
> >columns have to
> >be primary key (or: together they are the primary key). How can I do
> >this using SQL? Using pgAdminII for Postgres7.2.2 on RH8.
> >
> >Thanks
> >
> >Huub
> >
> >
> >---------------------------(end of
> >broadcast)---------------------------
> >TIP 4: Don't 'kill -9' the postmaster
> >
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly

Thanks..problem solved..

Huub




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

* Re: primary keys
@ 2002-11-07 14:35  Bruno Wolff III <bruno@wolff.to>
  parent: Huub <v.niekerk@freeler.nl>
  4 siblings, 0 replies; 10+ messages in thread

From: Bruno Wolff III @ 2002-11-07 14:35 UTC (permalink / raw)
  To: Huub <v.niekerk@freeler.nl>; +Cc: pgsql-sql

On Wed, Nov 06, 2002 at 15:18:38 +0100,
  Huub <v.niekerk@freeler.nl> wrote:
> Hi,
> 
> I want to create a table which has 2 columns, and both columns have to 
> be primary key (or: together they are the primary key). How can I do 
> this using SQL? Using pgAdminII for Postgres7.2.2 on RH8.

You can use a PRIMARY KEY table constraint. You can the SQL command
documentation for the CREATE TABLE command.



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

* Re: primary keys
@ 2002-11-07 14:49  Tomasz Myrta <jasiek@klaster.net>
  parent: Huub <v.niekerk@freeler.nl>
  4 siblings, 0 replies; 10+ messages in thread

From: Tomasz Myrta @ 2002-11-07 14:49 UTC (permalink / raw)
  To: Huub <v.niekerk@freeler.nl>; +Cc: pgsql-sql

Uz.ytkownik Huub napisa?:
 > Hi,
 >
 > I want to create a table which has 2 columns, and both columns have to
 > be primary key (or: together they are the primary key). How can I do
 > this using SQL? Using pgAdminII for Postgres7.2.2 on RH8.
Dependent on what you need:
1) you can create primary key based on 2 fields
2) you can't create 2 primary keys - but you can create primary key on 
first field and create unique index on second one.
Tomasz Myrta




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

* Re: primary keys
@ 2002-11-07 15:12  Sangeetha Rao <srao@carolina.rr.com>
  parent: terry@greatgulfhomes.com
  1 sibling, 0 replies; 10+ messages in thread

From: Sangeetha Rao @ 2002-11-07 15:12 UTC (permalink / raw)
  To: pgsql-sql

How do you select these sub Primary Keys?
I tried using Shift-Select, Ctrl_Selec, but doesn't work.
Thanks
Sangeetha

-----Original Message-----
From: pgsql-sql-owner@postgresql.org
[mailto:pgsql-sql-owner@postgresql.org]On Behalf Of
terry@greatgulfhomes.com
Sent: Thursday, November 07, 2002 8:54 AM
To: 'Huub'; pgsql-sql@postgresql.org
Subject: Re: [SQL] primary keys


A table can only have ONE primary key.  It can have additional indexes with
a UNIQUE restriction, thereby forcing the second field to be as good as a
primary key.

That is probably what you are looking for, however, you can also in PG Admin
II select multiple fields as being the member of the primary key.


Terry Fielder
Network Engineer
Great Gulf Homes / Ashton Woods Homes
terry@greatgulfhomes.com



> -----Original Message-----
> From: pgsql-sql-owner@postgresql.org
> [mailto:pgsql-sql-owner@postgresql.org]On Behalf Of Huub
> Sent: Wednesday, November 06, 2002 9:19 AM
> To: pgsql-sql@postgresql.org
> Subject: [SQL] primary keys
>
>
> Hi,
>
> I want to create a table which has 2 columns, and both
> columns have to
> be primary key (or: together they are the primary key). How can I do
> this using SQL? Using pgAdminII for Postgres7.2.2 on RH8.
>
> Thanks
>
> Huub
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>


---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly




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


end of thread, other threads:[~2002-11-07 15:12 UTC | newest]

Thread overview: 10+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1998-05-18 07:48 primary keys Perry Seleski <seleski@ronix.ptf.hro.nl>
1998-05-18 12:29 ` Marin D <marin@iclub.techno-link.com>
2002-11-06 14:18 primary keys Huub <v.niekerk@freeler.nl>
2002-11-07 13:54 ` terry@greatgulfhomes.com
2002-11-07 14:29   ` Huub <v.niekerk@freeler.nl>
2002-11-07 15:12   ` Sangeetha Rao <srao@carolina.rr.com>
2002-11-07 14:01 ` Rachel.Vaudron <rachel@lazaret.unice.fr>
2002-11-07 14:28 ` Achilleus Mantzios <achill@matrix.gatewaynet.com>
2002-11-07 14:35 ` Bruno Wolff III <bruno@wolff.to>
2002-11-07 14:49 ` Tomasz Myrta <jasiek@klaster.net>

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