Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialSeth Warner
5,348 PointsWhat if you wanted to just change the column type, and not the name as well?
would you just use
This being table name. This being column name. l l V V ALTER TABLE .....CHANGE COLUMN.....YEAR;
PS I know I did not have to use the keyword "COLUMN".
So you just wouldn't use the old column type, just add the new one, with the column name?
3 Answers
gareth o'connor
1,755 PointsCHANGE allows you change both the column name and type in one (as per below). MODIFY makes more sense if you just need to change the type.
ALTER TABLE tablename CHANGE columnname newcolumnname INTEGER;
gareth o'connor
1,755 PointsALTER TABLE tablename MODIFY columnname INTEGER;
Seth Warner
5,348 Pointsso CHANGE is only for what then, only changing column names and not column types?
gareth o'connor
1,755 PointsNo prob, Send them a suggestion so that the next poor fella isn't left scratching his head!!
Seth Warner
5,348 Pointshaha oh they know me QUITE to well lol, and I shall!
Seth Warner
5,348 PointsSeth Warner
5,348 PointsOOOhhhhhHHHhhhHHhhhhh...IIii gotcha. THANK you. that is VARY important! I wish they said that in the video!