Science, Tech, Math › Computer Science How to Change a Column Size or Type in MySQL Use ALTER TABLE and MODIFY commands to change a MySQL column Share Flipboard Email Print courtneyk/Getty Images Computer Science PHP Programming MySQL Commands Tutorials Perl Python Java Programming Javascript Programming Delphi Programming C & C++ Programming Ruby Programming Visual Basic View More By Angela Bradley Angela Bradley Computer Science Expert B.A, History, Eastern Oregon University Angela Bradley is a web designer and programming expert with over 15 years of experience. An expert in iOS software design and development, she specializes in building technical hybrid platforms. Learn about our Editorial Process Updated on September 19, 2018 Just because you made a MySQL column one type or size doesn't mean that it has to stay that way. Changing the column type or size in an existing database is simple. Changing a Database Column Size and Type You change a column size or type in MySQL using the ALTER TABLE and MODIFY commands together to make the change. Let's say, for example, that you have a column named "State" on a table named "Address" and you previously set it up to hold two characters, expecting people to use 2-character state abbreviations. You find that several people entered entire names instead of 2-character abbreviations, and you want to allow them to do this. You need to make this column larger to allow the full state names to fit. Here is how you do it: ALTER TABLE address MODIFY state VARCHAR(20) ; In generic terms, you use the ALTER TABLE command followed by the table name, then the MODIFY command followed by the column name and new type and size. Here is an example: ALTER TABLE tablename MODIFY columnname VARCHAR(20) ; The maximum width of the column is determined by the number in parentheses. The type is identified by VARCHAR as being a variable character field. About VARCHAR The VARCHAR(20) in the examples can change to whatever number is appropriate for your column. VARCHAR is a character string of variable length. The maximum length—in this example it is 20—indicates the maximum number of characters you want to store in the column. VARCHAR(25) could store up to 25 characters. Other Uses for ALTER TABLE The ALTER TABLE command can also be used to add a new column to a table or to remove an entire column and all its data from a table. For example to add a column, use: ALTER TABLE table_name ADD column_name datatype To delete a column, use: ALTER TABLE table_name DROP COLUMN column_name Cite this Article Format mla apa chicago Your Citation Bradley, Angela. "How to Change a Column Size or Type in MySQL." ThoughtCo, Aug. 28, 2020, thoughtco.com/change-columns-size-type-in-mysql-2693875. Bradley, Angela. (2020, August 28). How to Change a Column Size or Type in MySQL. Retrieved from https://www.thoughtco.com/change-columns-size-type-in-mysql-2693875 Bradley, Angela. "How to Change a Column Size or Type in MySQL." ThoughtCo. https://www.thoughtco.com/change-columns-size-type-in-mysql-2693875 (accessed March 20, 2023). copy citation