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
Anleitung zur Übung
- Add the column
EmailtoPerson. - Delete the column
BirthdayfromPerson.
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
-- Add the column EMail to Person
___ ___ Person
___ ___ VARCHAR(255);
-- Delete the column Birthday of Person
___ ___ Person
___ ____ ___;
-- Check the table definition
SELECT *
FROM Person;