DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: primary key

  1. #1
    Join Date
    Feb 2002
    Posts
    2
    hello
    i am a new user of SQL and Oracle8i at learning stage.i am facing difficulty with foreign key constraint.I make two tables one is 'master' in which field 'roll_no' has primary key then in second table 'fee' again 'roll_no' field (with same datatype and size) is defined as column level foreign key.i want to assign one more field in table 'master' as primary key for which i tried to execute following comman
    ALTER TABLE master ADD primary key(house_no);

    with the execution of this command i got the following message:
    "table can have only one primary key"
    i tried to remove primary key but it was referenced by some foriegn keys.then i tried to removr foreign key but no command run successfully and i tried to voilate the foreign key constraint and used the constraint shown by message to drop foreign key with following command:
    "alter table fee drop constraint school.sys_c001262;"
    but unsuccessful.Error message was
    "Invalid alter table option"

    please suggest me how can i solve this problem and can add one more primary key in master table and how can i remove foriegn key.Any help will be highly appreciated
    Summi

  2. #2
    Join Date
    Oct 2001
    Location
    Madrid, Spain
    Posts
    763
    Hi,

    If you have a composite primary key, then you have to drop the PK you have created and after

    alter table XXXX add primary key (column1,column2 ...,columnN);

    Hope that helps

    Angel

Posting Permissions

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


Click Here to Expand Forum to Full Width