Saturday, July 23, 2011

Alter Table Drop Column Syntax


In MySQL, the SQL syntax forALTER TABLE Drop Column is
ALTER TABLE "table_name"
DROP "column 1"

In Oracle and SQL Server, the SQL syntax for ALTER TABLE Drop Column is
ALTER TABLE "table_name"
DROP COLUMN "column 1"

Let's look at the example. Assuming our starting point is the "customer" table created in the CREATE TABLEsection:
Table customer
Column NameData Type
First_Namechar(50)
Last_Namechar(50)
Addresschar(50)
Citychar(50)
Countrychar(25)
Birth_Datedate

Our goal is to drop the "Birth_Date" column. To do this, we key in:
MySQL:
ALTER table customer drop Birth_Date;
SQL Server:
ALTER table customer drop column Birth_Date;
Oracle:
ALTER table customer drop column Birth_Date;
Resulting table structure:
Table customer
Column NameData Type
First_Namechar(50)
Last_Namechar(50)
Addresschar(50)
Citychar(50)
Countrychar(25)

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Deep's | Bloggerized by Deep - Deep's Templates | ElearSQL-Server