SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: primary key

  1. #1
    SitePoint Member
    Join Date
    Aug 2001
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    primary key

    If you have two columns in a database table and you want the primary key to be both of them ie. a composite key because this is only way to make it unique - how do you set this up when you create the table.
    Mysql won't let you nominate them both as primary keys so what do you do.

    Kerrilyn
    signature

  2. #2
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    eg:

    CREATE TABLE Foo(
    bar INT NOT NULL,
    zoot CHAR(8),
    PRIMARY KEY (bar, zoot)
    );

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •