1. Home
  2. Computing & Technology
  3. PHP / MySQL

Alter Table - MySQL Command

By Angela Bradley, About.com

Drop Column:
alter table icecream drop column flavor ;
Drop Column is used to remove an entire column and all its data from a table.
Add Column:
alter table icecream add column flavor varchar (20) ;
Add Column is used to add a column to your existing table.
Change:
alter table icecream change taste flavor varchar (10) ;
Change is used to change the column name. In our example it changes "taste" to be "flavor".
Add Unique:
alter table icecream add unique (quantity)
Add unique adds a new column to your table only if it does not already exist.
Modify:
alter table icecream modify flavor VARCHAR(35) ;
Modify is used to change a column's size. In our example we increase the size of the "flavor" column to 35 characters.

Explore PHP / MySQL

More from About.com

  1. Home
  2. Computing & Technology
  3. PHP / MySQL
  4. Learn MySQL
  5. Alter Table MySQL - Alter Table SQL - Alter Table

©2008 About.com, a part of The New York Times Company.

All rights reserved.