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 Name | Data Type |
First_Name | char(50) |
Last_Name | char(50) |
Address | char(50) |
City | char(50) |
Country | char(25) |
Birth_Date | date |
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