ALTER Command in SQL Syntax

ALTER Command in SQL:

This command can be used to add columns to the table, change their sizes, change their data types or add or delete constraints. It has the following syntax:

ALTER TABLE <table-name> [Options];

ADD Option:

ADD keyword is used to add column or constraints to the table. It has the following syntax:

ALTER TABLE EMPLOYEE ADD PHONE_NO CHAR (10);

The above statement will add a new column PHONE_NO to the EMPLOYEE table.

MODIFY Option:

The Modify option can change the data type, column width and constraints of an existing column. It hat following syntax:

ALTER TABLE EMPLOYEE MODIFY EMP_NAME VARCHAR (25);

DROP Option:

To remove the constraints imposed can be used. It has the following syntax:

ALTER TABLE EMPLOYEE DROP CONSTRAINT PIN_CODE;