SQL TP 1st Alter Command
SQL TP 1st Alter Command
• Syntax. ALTER TABLE. table name [alter option ...]; Where, the alter option
depends on the type of operation to be performed on a table.
1. Adding a New Column Using the ALTER Command
We can add a new column to an existing table using the ALTER command
in SQL. In this example, we will add a new column E_Total in the Salary table.
Alter Table Salary
Add E_total Number;
Select * From Salary;
Output:-
2. Modifying an Existing Column With the ALTER Command in SQL
In this example, we will modify the name of the E_Total column that
we just created in the previous section.
Alter Table Salary
Rename Column E_total To E_total_salary;
Select * From Salary;
Output:-
3. Dropping an Existing Column With the ALTER Command
We can drop any existing column from a table with the ALTER Command in
SQL. Here’s an example where we will drop the E_Total_Salary column.
Alter Table Salary
Drop Column E_total_salary;
Select * From Salary;
Output:-