Alter Command in SQL

Alter command in SQL is used to add, delete, or modify columns in an existing table. Alter in SQL is will help to make changes in the existing columns like add columns or delete columns.

Watch this Alter Command in SQL Tutorial video

Alter Command in SQL - Alter Column - Alter Table

Alter Table Add Column

To add a column in an existing table.

ALTER TABLE table_name
ADD column_name datatype;

Alter Table Drop Column

To delete a column from a table.

ALTER TABLE table_name
DROP COLUMN column_name;

Become a Database Architect

Example of Alter Query in SQL

In this example we will look at how to add a column “Year” in a Student_details table.

ALTER TABLE Student_details
ADD Year int;

Course Schedule

Name Date
SQL Training 2022-12-10 2022-12-11
(Sat-Sun) Weekend batch
View Details
SQL Training 2022-12-17 2022-12-18
(Sat-Sun) Weekend batch
View Details
SQL Training 2022-12-24 2022-12-25
(Sat-Sun) Weekend batch
View Details

Leave a Reply

Your email address will not be published. Required fields are marked *