Re: Error 1075 when dropping primary index
Posted by:
Lena Oan
Date: December 15, 2022 03:55AM
MySQL is returning that error (most likely) because there is no unique index defined on the id column. (MySQL requires that there be a unique index. The other possibility, which you would have already figured out, is that there can be only one column defined as AUTO_INCREMENT within the table.)
To get that column to be an AUTO_INCREMENT, you can add either a UNIQUE constraint or a PRIMARY KEY constraint on the id column. For example:
ALTER TABLE `blog` ADD CONSTRAINT `blog_ux` UNIQUE (`id`) ;
(Note that this statement will return an error if any duplicate values exist for the id column.)
Alternatively, you can make the id column the PRIMARY KEY of the table (if the table doesn't already have a PRIMARY KEY constraint defined).
ALTER TABLE `blog` ADD PRIMARY KEY (`id`) ;
(Note that this statement will return an error if any duplicate value exist for the id column, OR if there are any NULL values stored in that column, of if there is already a PRIMARY KEY constraint defined on the table.)
Subject
Written By
Posted
December 10, 2022 02:21PM
Re: Error 1075 when dropping primary index
December 15, 2022 03:55AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.