SQL Alter Table


ALTER Table Query

IN SQL ALTER TABLE statement is used to add, delete, or modify columns in an existing table.
ALTER TABLE statement is also used to add and drop various constraints on an existing table.

The ALTER statement in SQL  is always used with "ADD", "DROP" and "MODIFY"




 ALTER TABLE - ADD Column in table

SQL>ALTER TABLE table_name ADD column_name datatype;

Example-

SQl>ALTER TABLE Customers ADD Email varchar(25);





ALTER TABLE - DROP Column in table

SQL>ALTER TABLE table_name DROP COLUMN column_name;

Example-

SQl>ALTER TABLE Customers DROP COLUMN Email; 




ALTER TABLE - ALTER/MODIFY  column in table 

SQL>ALTER TABLE table_name MODIFY COLUMN column_name datatype;

Post a Comment

0 Comments