Yes, you can have multi-column keys. see the manual, para. 6.5.3 CREATE
TABLE Syntax
-Original Message-
From: Brendin [mailto:[EMAIL PROTECTED]]
Sent: Monday, November 12, 2001 12:37 PM
To: [EMAIL PROTECTED]
Subject: primary key based on unique value for two columns
I would like to
Brendin wrote:
I would like to have a table that has a primary key defined on a
combination of two columns in the table. In other words a unique key
based upon the values in two columns.
I don't think I am able to do this in mysql. I think you can only have
a primary key on one column
Hi
You are wrong.
Just try for example:
create table test(
pk1 int not null,
pk2 int not null,
primary key(pk1,pk2)
);
Regards
Daniel £a
e-direct Polska sp. z o.o.
I would like to have a table that has a primary key defined on a
combination of two columns in the table. In other words a unique key
based upon the values in two columns.
I don't think I am able to do this in mysql. I think you can only have
a primary key on one column and not on a
You can't use a primary key for that, but you CAN make a unique two-column
key:
ALTER TABLE MyTable ADD UNIQUE MyNewIndex (Column1,Column2)
- Jonathan
-Original Message-
From: Brendin [mailto:[EMAIL PROTECTED]]
Sent: Monday, November 12, 2001 10:37 AM
To: [EMAIL PROTECTED]
Subject:
: primary key based on unique value for two columns
Brendin wrote:
I would like to have a table that has a primary key defined on a
combination of two columns in the table. In other words a unique key
based upon the values in two columns.
I don't think I am able to do this in mysql. I
This will work thanks... That's what I want a unique key based on
two columns.
-Original Message-
From: Jonathan Hilgeman [mailto:[EMAIL PROTECTED]]
Sent: Monday, November 12, 2001 12:09 PM
To: 'Brendin'; [EMAIL PROTECTED]
Subject: RE: primary key based on unique value for two
sure you can
CREATE TABLE xx (field1 INT NOT NULL,field2 INT NOT NULL,PRIMARY KEY
(field1,field2))
and you have table xx with unique key in two fields
hand
primoz
- Original Message -
From: Brendin [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, November 12, 2001 7:37 PM
.
- Jonathan
-Original Message-
From: Bill Adams [mailto:[EMAIL PROTECTED]]
Sent: Monday, November 12, 2001 11:05 AM
To: Brendin
Cc: [EMAIL PROTECTED]
Subject: Re: primary key based on unique value for two columns
Brendin wrote:
I would like to have a table that has a primary key defined