With ALTER we can modify an existing table. We can add, delete, edit fields in the table.
Structure:
add column:
ALTER TABLE table_name ADD column_name data_type;
drop column:
ALTER TABLE table_name DROP column_name data_type;
Oracle, MYSQL:
ALTER TABLE table_name MODIFY column_name data_type;
SQL Server, PostrgreSQL:
ALTER TABLE table_name ALTER COLUMN column_name TYPE data_type;
Example1:
We have table with this data:
Table Staff
STAFFID | STAFF_NAME | SUPERVISORID |
---|---|---|
1 | Frank | 3 |
2 | Helena | 3 |
3 | Julia | - |
4 | Thomas | 2 |
ALTER TABLE Staff ADD TestColumn NUMBER;
I give people clear, functional, and proven instructions. I gently guide them so that they can fulfill their IT dreams.