SQL alter table

ALTER TABLE statement is used to add, delete, or modify columns in an existing table.


To Add a column

ALTER TABLE table_name
ADD column_name datatype ;
ALTER TABLE table-name add(column-name1 datatype1, column-name2 datatype2, column-name3 datatype3);



To delete a column

ALTER TABLE table_name
DROP COLUMN column_name ;

Must Read:

some database systems don't allow deleting a column.




To change the data type of a column


SQL Server / MS Access:

ALTER TABLE table_name
ALTER COLUMN column_name datatype;

My SQL / Oracle:


ALTER TABLE table_name
MODIFY column_name datatype;



To Rename a column

Using alter command you can rename an existing column. Following is the Syntax,

alter table table-name rename old-column-name to column-name;

Here is an Example for this,

alter table Student rename address to Location; 

The above command will rename address column to Location.