Re:cooments
Its not good.Its very Good and helpful.
Thanks sourcecodeester.com
The ALTER TABLE statement is used to change the structure of an existing table like adding, deleting, or modifying of column.
SQL ALTER TABLE Syntax
To add a new column to the existing table use the following syntax:
To remove a column from a table use the following syntax:
To modify a column from a table use the following syntax:
Consider the following table for this exercise
Users
Firstname | Lastname | Salary | DeptID |
---|---|---|---|
John | Smith | 1000 | 1 |
Mathew | Simon | 3000 | 1 |
Bill | Steve | 2200 | 1 |
Amanda | Rogers | 1800 | 2 |
Steve | Hills | 2800 | 2 |
Steve | jobs | 2400 | 2 |
bill | cosby | 700 | 3 |
Example # 1
Result of the Query
Firstname | Lastname | Salary | DeptID | Phone |
---|---|---|---|---|
John | Smith | 1000 | 1 | |
Mathew | Simon | 3000 | 1 | |
Bill | Steve | 2200 | 1 | |
Amanda | Rogers | 1800 | 2 | |
Steve | Hills | 2800 | 2 | |
Steve | jobs | 2400 | 2 | |
bill | cosby | 700 | 3 |
The resulted table is now formed with an additional column of Phone that we created with the alter table statement.