Did you find this useful?
Socialize it today.


SQL ALTER Statement

Wednesday, January 04, 2012

tags SQL

The SQL ALTER statement is used to add, modify, or delete fields in an existing database table.

Employees Table



employeeIDemployeeNameaccountCreated
1000John Smith1995-12-03 13:23:30.657
1001Fred White2001-10-12 09:41:44.125
1002Jane Scott1998-05-01 11:36:16.334
1003Samuel Williams1991-01-03 15:19:51.293

Syntax



ALTER TABLE tableName
ADD columnName dataType


ALTER TABLE tableName
ALTER COLUMN columnName dataType


ALTER TABLE tableName
DROP COLUMN columnName


Example



ALTER TABLE Employees
DROP COLUMN accountCreated


Results



employeeIDemployeeName
1000John Smith
1001Fred White
1002Jane Scott
1003Samuel Williams

The ALTER Statement used in this example deleted the 'accountCreated' field by using the DROP keyword in the statement.

Please help us spread the word by socializing it today!

email contact us

Did you find something wrong with the information on this page? Please take a moment to report it to us so that we can continue to improve the quality of the information on this site. Click here to report an issue with this page.



Recommended Books & Training Resources

Head First SQL: Your Brain on SQL A Learners Guide SQL Cookbook