Reputation: 4014
I'm trying to remove Auto_Increment from the column
_id in my MySQL database. However that column
is the primary key
for the table and when I'm using this command
ALTER TABLE Profile
MODIFY _id INT PRIMARY KEY NOT NULL
I get an error telling me that I can't do that since there are other tables which references the primary key
.
My question is therefore: Is there a way to get around this problem?
Upvotes: 5
Views: 4925
Reputation: 2394
the easiest and fastest way is the following:
set foreign_key_checks = 0;
alter table Profile change column _id _id INT NOT NULL;
set foreign_key_checks = 1;
found here
Upvotes: 15
Reputation: 704
Thre options:
1.Delete relationship before making this change.
2.Delete other table/s before making this change.
3.Alter relationship(tables) with somthing like on update / cascade (not sure if this will help)
Upvotes: 1