[thelist] mysql primary key multiple columns

Liz Lawson lizlawson at charitycards.co.uk
Wed Aug 30 03:51:43 CDT 2000


yes

in your create table statement

PRIMARY KEY (col1, col2)

With as many columns as you need.

(I'm very much not a database design person, but I understand you shouldn't
make this your PRIMARY key if you might ever need to use it as a foreign key
in another table. If this could be a possibility, maybe make the column
combination a unique, non-primary key and add an auto-increment column as
your primary key.)


Liz

-----Original Message-----
From: Peter Van Dijck <peter at vardus.com>
To: thelist at lists.evolt.org <thelist at lists.evolt.org>
Date: 29 August 2000 11:52
Subject: [thelist] mysql primary key multiple columns


>Can I set multiple columns as primary key in mysql so that it is the
>COMBINATION that is unique?
>Peter
>
>
>
>---------------------------------------
>For unsubscribe and other options, including
>the Tip Harvester and archive of TheList go to:
>http://lists.evolt.org Workers of the Web, evolt !
>
>






More information about the thelist mailing list