1

Hello i have table which has a primary key now on the basis of my need i have to create another primary key means the second primary key but its showing this error message

"ALTER TABLE `abc` ADD PRIMARY KEY(`zzz`)
MySQL said: Documentation

#1068 - Multiple primary key define"

Here is the command:

ALTER TABLE `ABC` ADD PRIMARY KEY(`ZZZ`)
Falko
  • 17,076
  • 13
  • 60
  • 105
  • One table can have only 1 primary key at a time. You can make it unique key rahter. So your approach is wrong. – Ankit Bajpai Jun 30 '14 at 06:15
  • whatever your need is,but you can't have two primary keys in a table,rather you can have composite primary key,check this out http://stackoverflow.com/questions/217945/can-i-have-multiple-primary-keys-in-a-single-table – nobalG Jun 30 '14 at 06:16

2 Answers2

1

Its impossible to have more than 1 primary key on single table. You can have composite primary key on combination of two columns.

DevelopmentIsMyPassion
  • 3,541
  • 4
  • 34
  • 60
0

You can only have one primary key. Change the first one or add a unique constraint.

Jens
  • 67,715
  • 15
  • 98
  • 113
  • http://stackoverflow.com/questions/217945/can-i-have-multiple-primary-keys-in-a-single-table – nobalG Jun 30 '14 at 06:16