Curriculum
Course: SQL
Login

Curriculum

SQL

SQL References

0/80

MySQL Functions

0/139

SQL Server Functions

0/84

SQL Quick Ref

0/1
Text lesson

ALTER

ALTER TABLE

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

It also facilitates adding and deleting various constraints within a table.

For instance, the following SQL statement adds an “Email” column to the “Customers” table.

Example

ALTER TABLE Customers
ADD Email varchar(255);

The provided SQL removes the “Email” column from the “Customers” table.

Example

ALTER TABLE Customers
DROP COLUMN Email;

ALTER COLUMN

The ALTER COLUMN command is utilized to alter the data type of a column in a table.

The subsequent SQL statement changes the data type of the “BirthDate” column in the “Employees” table to the “year” type.

Example

ALTER TABLE Employees
ALTER COLUMN BirthDate year;