help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • izzo
    New Member
    • Nov 2006
    • 5

    help

    hi i need some help.I tried using alter table tablename <modify columnname datatype> to change the primary key of the table but it didnt work.I was prompted that there is an error because of using the term modify.what is the command that i should use?
  • willakawill
    Top Contributor
    • Oct 2006
    • 1646

    #2
    Originally posted by izzo
    hi i need some help.I tried using alter table tablename <modify columnname datatype> to change the primary key of the table but it didnt work.I was prompted that there is an error because of using the term modify.what is the command that i should use?
    Hi
    I don't think you can modify the primary key. You need to delete it and then create a new one on a different column

    Comment

    • aaryan
      New Member
      • Nov 2006
      • 82

      #3
      first drop the primary key constraint
      alter table tablename drop pk_constraint
      then add a new constraint to whatever column you want to add it on to, making sure that the values in the column obliges the rules of primary key.
      alter table tablename add constraint pk_col1 primary key(col1)

      hope this one helps u

      Comment

      Working...