Using the MySQL
ALTER TABLE command, you can easily change an existing columns’ name and datatype. With just a few clicks, you can do the same in the phpMyAdmin visual web interface. For many developers, this interface is the one they lean on most while programming so it can’t hurt to know how to do it yourself should you find yourself programming in this environment…
If you enjoy the content written here, by all means, share this blog and your favorite post(s) with others who may benefit from or like it as well. Since coffee is my favorite drink, you can even buy me one if you would like!
Suppose we have a table with these 3 columns:
Our goal is to rename the title column to paper_title and to also change the datatype from
To get started, simply click the checkbox on the far left of the columns’ row you want to change.
After checking the checkbox, select the change action (just beside the pencil icon). You are presented with this view of the column and accompanying metadata:
This section allows you to change the column name, the data type, and if applicable – the Length/Values value (among other metadata that is presented for a column in this view). As you see in the screenshot below, I indeed changed the datatype to
VARCHAR and set a Length of 150.
After clicking the Save button in the far lower right (not shown), you can revisit the overall table Structure tab and see the implemented changes
Notice the exact MySQL command is shown just above the table column row metadata. This is the command that was executed to carry out the changes and is a great way to learn what the different actions are when you execute them. Just be extremely careful with any Data Definition Language commands…
Like what you have read? See anything incorrect? Please comment below and thanks for reading!!!
A Call To Action!
Thank you for taking the time to read this post. I truly hope you discovered something interesting and enlightening. Please share your findings here, with someone else you know who would get the same value out of it as well.
Visit the Portfolio-Projects page to see blog post/technical writing I have completed for clients.
Have I mentioned how much I love a cup of coffee?!?!
Be sure and visit the “Best Of” page for a collection of my best blog posts.
Josh Otwell has a passion to study and grow as a SQL Developer and blogger. Other favorite activities find him with his nose buried in a good book, article, or the Linux command line. Among those, he shares a love of tabletop RPG games, reading fantasy novels, and spending time with his wife and two daughters.
Disclaimer: The examples presented in this post are hypothetical ideas of how to achieve similar types of results. They are not the utmost best solution(s). The majority, if not all, of the examples provided, is performed on a personal development/learning workstation-environment and should not be considered production quality or ready. Your particular goals and needs may vary. Use those practices that best benefit your needs and goals. Opinions are my own.
One thought on “Use phpMyAdmin to change column name and datatype in MySQL”