- ALTER TABLE command is used to modify table structure.
- We can add new column, remove existing column or change data type and size by using alter table command.
- If records are available in a specific column then we cannot decrease its size but can increase.
To Add new Column:
ALTER TABLE <table name> ADD <new_column_name><data type> (size)…) ;
ALTER TABLE student ADD ( city varchar2(15) );
To Modify Existing Column:
ALTER TABLE <table name> MODIFY <column_name><new data type> (size)…) ;
ALTER TABLE student MODIFY (city varchar2(20)) ;
To Drop Exiting Column:
ALTER TABLE <table name> DROP COLUMN <column_name>;
ALTER TABLE student DROP COLUMN city;
- Alter table command cannot be used for renaming columns and table.