SQL ALTER TABLE Statement
SQL ALTER TABLE statement is used to modify the table structure, you can add column(s), drop column(s), modify column(s) or work on constraints.
Here we will use Student table for practice.
In this table we will add City column, to do so we can write below query.
ALTER TABLE Student ADD City varchar(20)
As you can see last column is added with the name of City.
To modify a column in a table you can write below query. Here we have modified data size from varchar(20) to varchar(50).
ALTER TABLE Student ALTER COLUMN City varchar(50)
If you want to drop a column from table then you can use below query.
ALTER TABLE Student DROP COLUMN City
So, City column will be dropped with data values in the table.
You can also work on constraints like add, modify or drop constraints with ALTER TABLE statements.
Reference: Manzoor Siddiqui [www.SQLServerLog.com]