In this article we will learn about the Azure SQL alter statement. In the previous article we have learned how create and connect to the Azure SQL database. If you are new to the Azure SQL, then please watch my following videos on the Azure SQL database.
How To Create Azure SQL DataBase
How To Connect Azure SQL DataBase Using SQL Management Studio
What is SQL Alter Table Statement?
Alter statement used to modify the structure of the existing table. The alter statement used is to add, drop the table column. It can also be used to change the data types of the column etc.
Let us consider we have the table having name Employee in our Azure SQL Server database having the following records,
Add Column To Existing Table Using Alter Statement
The following SQL query will add the new column Salary into the existing table.
ALTER TABLE Employee ADD salary decimal(50);
You can alter the multiple columns at a time, the following query will alter the multiple columns of the existing table.
ALTER TABLE Employee ADD ( Location varchar (50), EmailID Varchar (50) )
ALTER TABLE Employee MODIFY Salary decimal(60);
ALTER TABLE Employee DROP COLUMN Salary;
Post a Comment