0

I created a composite key constraint

ALTER TABLE authorprofile  
  ADD PRIMARY KEY (a_id, a_firstname);  

I then tried to add an identifier like so:

ALTER TABLE authorprofile  
  ADD CONSTRAINT pk_id_firstname PRIMARY KEY (a_id, a_firstname); 

but i get a "multiple primary key defined error"

Tarik
  • 10,810
  • 2
  • 26
  • 40
Subo
  • 27
  • 4
  • show us please also the create table, i am sure there is already a primary key, and you can only have one, so delet the old one first – nbk Aug 16 '20 at 17:53
  • That is a composite primary key. See https://stackoverflow.com/questions/5835978/how-to-properly-create-composite-primary-keys-mysql – Tarik Aug 16 '20 at 17:55
  • CREATE TABLE AuthorProfile ( a_id INT NOT NULL, a_firstname CHAR(50) NOT NULL, a_lastname CHAR(50), a_booktitle VARCHAR(50), a_genre VARCHAR(10), isbn VARCHAR(20) ); ALTER TABLE authorprofile ADD PRIMARY KEY (a_id, a_firstname); that is the create tale block – Subo Aug 16 '20 at 18:48

0 Answers0