I am trying to change the data type of a primary key in table A from INT(11) to CHAR(11). However, this primary key is a foreign key in tables B and C. SQL is giving me an error whenever I try to change the value type of the primary key. Here is the query that I tried:

ALTER TABLE CUSTOMER CHANGE CUSTID CUSTID CHAR( 11 ) NOT NULL

The error I am getting is #1025. Do I need to use a double nested query to change its data type in tables A, B, and C? I'm a bit lost here.

Drop the foreign key relations.
Modify all three tables to the same data type.
Re-create the foreign key relations.

It worked. Thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.