Data Defination Language (DDL)
Alter Table
We have now see how to create, drop and index a table but sometimes we might want to change or alter an existing table once it has been created. This can be achieved with the keyword ALTER. Like create, alter has many variations, of which a full syntax definition can be found at mysql Online Reference Manual But for our purposes the syntax would look like:
The first syntax adds a column definition or definitions to the specified table while the second drops a column or columns from the specified table.
For example:
ALTER TABLEemployee ADD COLUMN salary
DECIMAL(7,2)
And
ALTER TABLE employee
DROP COLUMN job;
It should be noted that any column added will we added to the end of the table and the column will be added as an optional column and cannot be defined as mandatory. When a column is dropped all the data in that column will be lost but the remaining table will remain intact.