#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    4
    Rep Power
    0

    Question Creating a Composite Key.....


    CREATE TABLE addresses OF address
    (
    houseNum PRIMARY KEY
    );


    This is how I create a primary key when creating a table.

    Does anyone know how I would create a primary key using both the house number and say the telephone number (ie. telNo), which in effect would be a composite key????
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    68
    Rep Power
    12
    create table addresses (

    houseNum NUMBER,
    telNo NUMBER,

    constraint pk_address primary key (houseNum,telNo)

    )

    Regards,
    Dan
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    4
    Rep Power
    0
    That gives me this error:-


    SP2-0734: unknown command beginning "constraint..." - rest of line ignored.
    SP2-0042: unknown command ")" - rest of line ignored.



    Its like as if it doesnt recogise the word "constraint" ???????
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    4
    Rep Power
    0
    Its okay, I got it!

    Thanks, you were right, with a little adjustment of the syntax.

IMN logo majestic logo threadwatch logo seochat tools logo