+ Reply to Thread
Results 1 to 4 of 4

Thread: How can I alter a primary key constraint

  1. #1

    How can I alter a primary key constraint

    when implementing my database i forgot to insert an addition primary key into a certain table and i want to alter that table to add the primary key , but i don`t know the syntax , could you give me the syntax please ?

  2. #2
    Junior Member
    Join Date
    Jan 2012
    Posts
    41
    The correct way is to drop the constraint with an Alter table and then recreate it.

    step 1 :
    Code:
    ALTER TABLE <Table_Name>
    DROP CONSTRAINT <constraint_name>
    step 2 :
    Code:
    ALTER TABLE <Table_Name>
    ADD CONSTRAINT <constraint_name> PRIMARY KEY (<Column1>,<Column2>)

  3. #3
    thank you it worked .

  4. #4
    Junior Member
    Join Date
    Jan 2012
    Posts
    41
    no problem at all , and if you have any other questions , i`d be pleased to answer them .

+ Reply to Thread

Tags for this Thread

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