Locked lesson.
About this lesson
Exercise files
Download this lesson’s related exercise files.
ALTER TABLE.docx59.1 KB ALTER TABLE - Solution.docx
59.6 KB
Quick reference
ALTER TABLE
The ALTER TABLE Command allows us to change the structure of the table itself.
When to use
Use this whenever you want to Add new columns to your table, or change current columns, or remove columns.
Instructions
To add a column named "Zip Code" with the data type of integer:
ALTER TABLE [dbo].[Current_Customers]
ADD "Zip Code" int
To change the data type of a column:
ALTER TABLE [dbo].[Current_Customers]
ALTER COLUMN "First Name" varchar(50)
To remove a column (drop the column):
ALTER TABLE [dbo].[Current_Customers]
DROP COLUMN 'Zip Code'
Hints & tips
- Alter Table allows us to Add or change column names and data types
- ALTER COLUMN lets us change the data type of a column
- ADD lets us add a new column
- DROP COLUMN deletes a column
Lesson notes are only available for subscribers.