SQL Alter Table Query is for Changing the table's structure. We can use Alter Table Command to Add a column to table, Remove a column and even Change an already available Column Data Type.
Alter for Adding a new Column
Syntax:
Alter table TableName add ColumnName DataType
Example on MySQL:
Alter table orders add tax float(6,2) after amount;
Example on MsSQL Server:
Alter table Product add Pstock int
Alter for Removing a Column
Syntax:
Alter table TableName drop ColumnName
Example on MySQL:
Alter table orders drop tax;
Example on MsSQL Server:
Alter table Product drop column Pstock
Alter for Changing a Column
Syntax:
Alter table TableName modify ColumnName datatype
Example on MySQL:
Alter table customers modify name char(45) not null;
Example on MsSQL Server:
Alter table Product alter column Pdesc varchar (150)