Get startedGet started for free

Changing a table structure

Another basic SQL operation is to add or delete a column from a table. This can be done using the ALTER TABLE syntax followed by the desired operation. The syntax for these operations is defined as follows.

To add a column named new to the Employee table:

ALTER TABLE Employee 
ADD new;

To delete a column named old from Employee:

ALTER TABLE Employee 
DROP COLUMN old

You have the task to add a new column Email and drop the column Birthday from the Person table.

This exercise is part of the course

Hierarchical and Recursive Queries in SQL Server

View Course

Exercise instructions

  • Add the column Email to Person.
  • Delete the column Birthday from Person.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

-- Add the column EMail to Person
___ ___ Person
___ ___ VARCHAR(255);

-- Delete the column Birthday of Person
___ ___ Person
___ ____ ___;

-- Check the table definition
SELECT * 
FROM Person;
Edit and Run Code