Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2004
    Posts
    106

    Unanswered: create table with multiple primary keys

    What is the sql to create table with multiple primary keys.

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    DROP TABLE (only kidding!)

    A can't have multiple primary keys

    izy
    currently using SS 2008R2

  3. #3
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Could you post your proposed schema?

  4. #4
    Join Date
    Feb 2004
    Posts
    106
    Create table Region (
    Region varchar,
    Market varchar
    )

    I want to make region and market a COMPOSITE primary key.

  5. #5
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    So you want to have multiple markets for a given region?

    I STRONGLY suggest you make two seperate tables. One for regions, one for markets.

    edit: just to play devil's advocate, if you do choose to use a "composite key", the only way you can really do that is to store a deliminated string. In which case, whenever you want to retrieve individual values in your "composite key", you'll need to write vba to parse the values into an array, most likely using split().
    Last edited by Teddy; 03-25-04 at 13:55.

  6. #6
    Join Date
    Sep 2001
    Location
    Chicago, Illinois, USA
    Posts
    601
    Doesn't anyone use the Access Help system ?

    Here's what I got . . .

    CREATE [ UNIQUE ] INDEX index
    ON table (field [ASC|DESC][, field [ASC|DESC], ...])
    [WITH { PRIMARY | DISALLOW NULL | IGNORE NULL }]

    So, in your instance, you might write . . .

    CREATE PK_RegionMarket ON Region (Region, Market) WITH PRIMARY

Posting Permissions

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