1. Computing

Discuss in my forum

How to change a column's size or type in MySQL

How to change a column's size or type in MySQL

By , About.com Guide

Just because you made a MySQL column one type or size doesn't mean that it has to stay that way. Let's say for example that you have a column named "state" on a table named "address" and you set it up to hold two characters, expecting people would all use abbreviations. You find that several people have entered "Wisconsin" instead of "WI" and you want to allow them to do this. You need to make this column larger to allow this to fit. Here is how you do it:

alter table address modify state VARCHAR(35) ;
In more generic terms, you use alter table followed by the table name, then modify followed by the column name and new type and size. Here is an example:

alter table tablename modify columnname VARCHAR(50) ;
  1. About.com
  2. Computing
  3. PHP / MySQL
  4. Learn MySQL
  5. Change Column Size MySQL - How to change a column's size or type in MySQL

©2013 About.com. All rights reserved.