Last answered:

07 Jun 2023

Posted on:

06 Jun 2023

0

Unique constraint assignment error message

Why is it giving me the error message of duplicate? 
ALTER TABLE customers
 ADD COLUMN gender ENUM('M','F') AFTER last_name;
 
 INSERT INTO customers (first_name, last_name, gender, email_address, number_of_complaints)
 VALUES ('John', 'Mackinley', 'M', 'john.mckinley@365datascience.com', 0);

06:03:14
ALTER TABLE customers  ADD COLUMN gender ENUM('M','F') AFTER last_name
0 row(s) affected Records: 0  Duplicates: 0  Warnings: 0

ALTER TABLE customers  ADD COLUMN gender ENUM('M','F') AFTER last_name
Error Code: 1060. Duplicate column name 'gender'
0.000 sec

1 answers ( 0 marked as helpful)
Instructor
Posted on:

07 Jun 2023

0

Hi Nike!
Thanks for reaching out!

 

You add two times the same column. Also, you should provide a value for the customer_id column. Please, use the following code:

ALTER TABLE customers ADD COLUMN gender ENUM('M','F') AFTER last_name;
 
INSERT INTO customers (customer_id, first_name, last_name, gender,email_address, number_of_complaints), VALUES (1, 'John', 'Mackinley', 'M', 'john.mckinley@365datascience.com', 0);


Hope this helps.
Best,
Tsvetelin

Submit an answer