Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Primary key problem

 
Alvin chew
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, i using code to add new primary key(cam_name) to table which already have existing primary key (cam_code), but somehow it give me ""Multiple primary key defined " error

i using following code to query


should i drop the existing primary key then only add both primary key together ?

like following

i found it tredious to do that, is there any better solution ? thank you very much for answering !

for another case, let say the table contains 3 primary key, and i want to drop only one of the primary key, what should i do ?
[ December 05, 2004: Message edited by: Alvin chew ]
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34178
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alvin,
Are you trying to add a column to the existing primary key or a new key entirely? A table can only have one primary key. You can add a unique constraint to any other column(s) though.

If you are trying to add a column to an existing primary key, some databases do not let you do this without dropping the table.
 
Alvin chew
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,Jeanne Boyarsky
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jeanne Boyarsky:
If you are trying to add a column to an existing primary key, some databases do not let you do this without dropping the table.


Its 'without dropping the table' or 'without dropping the key'. If 'table' then you must be talking about MS ACCESS.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34178
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adeel,
That is correct. I was trying to keep my comments non-database specific.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic