We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,289 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Altering Data Types

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.

3
Contributors
2
Replies
13 Hours
Discussion Span
1 Year Ago
Last Updated
3
Views
Question
Answered
BThomps
Newbie Poster
4 posts since Mar 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

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

smantscheff
Nearly a Posting Virtuoso
1,297 posts since Oct 2010
Reputation Points: 321
Solved Threads: 270
Skill Endorsements: 8

It worked. Thank you.

BThomps
Newbie Poster
4 posts since Mar 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0
Question Answered as of 1 Year Ago by smantscheff

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0642 seconds using 2.66MB