LoslegenKostenlos loslegen

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.

Diese Übung ist Teil des Kurses

Hierarchical and Recursive Queries in SQL Server

Kurs anzeigen

Anleitung zur Übung

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

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

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

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

-- Check the table definition
SELECT * 
FROM Person;
Code bearbeiten und ausführen