English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Usage and examples of the SQL ALTER keyword

SQL Keywords Reference

ALTER TABLE

The ALTER TABLE command is used to add, delete, or modify columns in a table.

ALTER TABLE command can also add and delete various constraints in the table.

The following SQL adds the 'Email' column to the 'Customers' table:

ALTER TABLE Customers
ADD Email varchar(255);

The following SQL deletes the 'Email' column from the 'Customers' table:

ALTER TABLE Customers
DROP COLUMN Email;

ALTER COLUMN

ALTER COLUMN command is used to change the data type of a column in the table.

The following SQL changes the data type of the 'BirthDate' column in the 'Employees' table to type year:

ALTER TABLE Employees
ALTER COLUMN BirthDate year;

SQL Keywords Reference