Difference between revisions of "Howto alter existing mysql table"
From thelinuxwiki
(Pushed from Themanclub.) |
Latest revision as of 15:45, 12 April 2013
commands run from mysql interactive prompt
Add new varchar column to the end of the table
>ALTER TABLE `tablename_here` ADD `new_column_name` VARCHAR( 255 ) NOT NULL ;
Add new integer column after an existing column in table
>ALTER TABLE `tablename_here` ADD `new_column_name` INT NOT NULL AFTER `existing_column` ;
This changes the column called "name" on the table called "people" to now allow 35 characters.
>alter table people modify name VARCHAR(35) ;
This removes the column "flavor" from the table called "icecream".
>alter table icecream drop column flavor;