Saturday, July 23, 2011

Alter Table Drop Constraint Syntax


The SQL syntax for ALTER TABLE Drop Constraint is
ALTER TABLE "table_name"
DROP [CONSTRAINT|INDEX] "CONSTRAINT_NAME"

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

Assume we want to drop the UNIQUE constraint on the "Address" column. To do this, we type in the following:
MySQL:
ALTER TABLE customer DROP INDEX con_first;
Note that MySQL uses DROP INDEX for index-type constraints such as UNIQUE. con_first is the name of the constraint.
Oracle:
ALTER TABLE customer DROP CONSTRAINT con_first;
SQL Server:
ALTER TABLE customer DROP CONSTRAINT con_first;

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

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