Constraints in sql | Sql constraint | Drop constraint in sql - sql - sql tutorial - learn sql




 drop constraint in sql
  • Constraints can be placed on a table to limit the type of data that can go into a table.
  • Since we can specify constraints on a table, there needs to be a way to remove this constraint as well.
  • In SQL, this is done via the ALTER TABLE statement.
  • Drop of constrain can remove primary, foreign and other keys from the column
  • SQL > ALTER TABLE > Drop Constraint Syntax
  • The SQL syntax to remove a constraint from a table is,
ALTER TABLE "table_name"
DROP [CONSTRAINT|INDEX] "CONSTRAINT_NAME";
  • Let's look at the example. Assuming our starting point is the Employee table created in the CREATE TABLE section:

Table Employee

Column Name Data Type
First_Name char(50)
Last_Name char(50)
Address char(50)
City char(50)
Country char(25)
Birth_Date datetime
  • Assume we want to drop the UNIQUE constraint on the "Address" column, and the name of the constraint is "Con_First." To do this, we type in the following:

MySQL:

ALTER TABLE Employee DROP INDEX Con_First;
  • Note that MySQL uses DROP INDEX for index-type constraints such as UNIQUE.

Oracle:

ALTER TABLE Employee DROP CONSTRAINT Con_First; 

SQL Server:

ALTER TABLE Employee DROP CONSTRAINT Con_First;

This tutorial provides more the basic needs and informations on sql tutorial , pl sql tutorial , mysql tutorial , sql server , sqlcode , sql queries , sql , sql formatter , sql join , w3schools sql , oracle tutorial , mysql , pl sql , learn sql , sql tutorial for beginners , sql server tutorial , sql query tutorial , oracle sql tutorial , t sql tutorial , ms sql tutorial , database tutorial , sql tutorial point , oracle pl sql tutorial , oracle database tutorial , oracle tutorial for beginners , ms sql server tutorial , sql tutorial pdf

Related Searches to Constraints in sql | Sql constraint | Drop constraint in sql

Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

We need money to operate the site, and almost all of it comes from our online advertising.

Please add wikitechy.com to your ad blocking whitelist or disable your adblocking software.

×