Multiple Primary Keys

Started by Isaías Cristiano Barrosoabout 23 years ago4 messagesgeneral
Jump to latest
#1Isaías Cristiano Barroso
isaias@unimedjm.com.br

Hi all,

How to create a table with multiple primary key?
I'm trying this manner but don't work.

CREATE TABLE A ( FIELD1 INT PRIMARY KEY, FIELD2 INT PRIMARY KEY);

and

CREATE TABLE A ( FIELD1 INT , FIELD2 INT , PRIMARY KEY(FIELD1, FIELD2);

But i've the following message:

ERROR: CREATE TABLE / PRIMARY KEY multiple primary keys for table 'A' are not allowed.

How to do?

Best Regards.

Isaías

#2Manfred Koizar
mkoi-pg@aon.at
In reply to: Isaías Cristiano Barroso (#1)
Re: Multiple Primary Keys

On Wed, 15 Jan 2003 11:14:04 -0200, Isa�as Cristiano Barroso <isaias@unimedjm.com.br>
wrote:

CREATE TABLE A ( FIELD1 INT PRIMARY KEY, FIELD2 INT PRIMARY KEY);
ERROR: CREATE TABLE / PRIMARY KEY multiple primary keys for table 'A' are not allowed.

The error message says it all.

CREATE TABLE A ( FIELD1 INT , FIELD2 INT , PRIMARY KEY(FIELD1, FIELD2);

^
This should work, if you add a ) here --------------------------------+

Servus
Manfred

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Isaías Cristiano Barroso (#1)
Re: Multiple Primary Keys

=?iso-8859-1?Q?Isa=EDas_Cristiano_Barroso?= <isaias@unimedjm.com.br> writes:

How to create a table with multiple primary key?

What? A table can only have one primary key, by definition.

What is it you're actually trying to accomplish?

regards, tom lane

#4Isaías Cristiano Barroso
isaias@unimedjm.com.br
In reply to: Isaías Cristiano Barroso (#1)
Re: Multiple Primary Keys

Thanks all by response.

Isaias
----- Original Message -----
From: "Manfred Koizar" <mkoi-pg@aon.at>
To: "Isa�as Cristiano Barroso" <isaias@unimedjm.com.br>
Cc: <pgsql-general@postgresql.org>
Sent: Wednesday, January 15, 2003 1:00 PM
Subject: Re: [GENERAL] Multiple Primary Keys

On Wed, 15 Jan 2003 11:14:04 -0200, Isa�as Cristiano Barroso

<isaias@unimedjm.com.br>

wrote:

CREATE TABLE A ( FIELD1 INT PRIMARY KEY, FIELD2 INT PRIMARY KEY);
ERROR: CREATE TABLE / PRIMARY KEY multiple primary keys for table 'A' are

not allowed.

Show quoted text

The error message says it all.

CREATE TABLE A ( FIELD1 INT , FIELD2 INT , PRIMARY KEY(FIELD1, FIELD2);

^
This should work, if you add a ) here --------------------------------+

Servus
Manfred