0% found this document useful (0 votes)
11 views4 pages

SQL TP 1st Alter Command

The SQL ALTER TABLE command is used to modify the structure of an existing table, allowing users to add, modify, or delete columns and constraints. Examples include adding a new column, renaming an existing column, and dropping a column from a table. The syntax for the command is 'ALTER TABLE table_name [alter option ...];' where the alter option varies based on the operation performed.

Uploaded by

arpitgulhane123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views4 pages

SQL TP 1st Alter Command

The SQL ALTER TABLE command is used to modify the structure of an existing table, allowing users to add, modify, or delete columns and constraints. Examples include adding a new column, renaming an existing column, and dropping a column from a table. The syntax for the command is 'ALTER TABLE table_name [alter option ...];' where the alter option varies based on the operation performed.

Uploaded by

arpitgulhane123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Alter Command:-

The SQL ALTER TABLE command is a part of Data Definition Language


(DDL) and modifies the structure of a table. The ALTER TABLE statement in
Structured Query Language allows you to add, modify, and delete columns of an
existing table. This statement also allows database users to add and remove various
SQL constraints on the existing tables.

• 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:-

You might also like