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.
ALTER TABLE Customers ADD Email varchar(255); |
The provided SQL removes the “Email” column from the “Customers” table.
ALTER TABLE Customers DROP COLUMN Email; |
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.
ALTER TABLE Employees ALTER COLUMN BirthDate year; |