The SQL ALTER statement is used to add, modify, or delete fields in an existing database table.
Employees Table
employeeID | employeeName | accountCreated |
1000 | John Smith | 1995-12-03 13:23:30.657 |
1001 | Fred White | 2001-10-12 09:41:44.125 |
1002 | Jane Scott | 1998-05-01 11:36:16.334 |
1003 | Samuel Williams | 1991-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
employeeID | employeeName |
1000 | John Smith |
1001 | Fred White |
1002 | Jane Scott |
1003 | Samuel Williams |
The ALTER Statement used in this example deleted the 'accountCreated' field by using the DROP keyword in the statement.
Did you find the page informational and useful? Share it using one of your favorite social sites.
Recommended Books & Training Resources