How to get past the following "Cannot change column 'xxx': used in a foreign key constraint"

Willem van Zyl
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 24, 2016

This question is in reference to Atlassian Documentation: MySQL Collation Repair: Table Level Changes

Example:

ALTER TABLE `CONTENT` MODIFY `CREATOR` varchar(255) CHARACTER SET UTF8 COLLATE utf8_bin;

ERROR 1832 (HY000): Cannot change column 'CREATOR': used in a foreign key constraint 'FK_CONTENT_CREATOR'

 

 

2 answers

1 accepted

4 votes
Answer accepted
Guilherme V.
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 31, 2016

You can disable the constraints checks, run the ALTER statement and then enable the constraint checker again:

SET foreign_key_checks = 0;
ALTER TABLE `CONTENT` MODIFY `CREATOR` varchar(255) CHARACTER SET UTF8 COLLATE utf8_bin;
SET foreign_key_checks = 1;

See if it helps...

Willem van Zyl
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 1, 2016

Thank you Guilherme.  Got my service up an running again.

Guilherme V.
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 2, 2016

You're welcome, buddy smile

Alesson
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 27, 2018

thank you guy.

Krishna Rathi
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 19, 2019

The above solution is not recommended on production though. You can try locking table before executing your commands and finally unlocking it.

Bongani Mlilo
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 20, 2019

Thank you.

0 votes
黄兵
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 14, 2018

Thank you for your reply and helped me solve the problem.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events