MySQL ALTER TABLE
MySQL ALTER TABLE statement that changes existing table structure such as adding or removing column, changing column attribute, etc.
ALTER TABLE table_name action1[,action2,…]
To alter an existing table:
- First, you specify the table name that you want to change after the
- Second, you list a set of actions that you want to apply to the table. An action can be anything such as adding a new column, adding primary key, renaming table, etc. The
ALTER TABLEstatement allows you to apply multiple actions in a single
ALTER TABLEstatement, each action is separated by a comma (,).
Ouery:-add New Colonm into exiting Table.
ALTER TABLE emp ADD COLUMN date varchar( 100 ) NULL AFTER salary;
Ouery:-Drop a column from exiting Table.
ALTER TABLE emp DROP COLUMN date;
Ouery:-Renaming table Name of exiting Table Name.
ALTER TABLE emp RENAME TO employee