• Skip to primary navigation
  • Skip to main content

Tech Honey

The #1 Website for Oracle PL/SQL, OA Framework and HTML

  • Home
  • HTML
    • Tags in HTML
    • HTML Attributes
  • OA Framework
    • Item in OAF
    • Regions in OAF
    • General OAF Topics
  • Oracle
    • statement
    • function
    • clause
    • plsql
    • sql
You are here: Home / Oracle / sql / DROPPING, DISABLING and ENABLING UNIQUE CONSTRAINT in Oracle SQL – PLSQL

DROPPING, DISABLING and ENABLING UNIQUE CONSTRAINT in Oracle SQL – PLSQL

October 31, 2012 by techhoneyadmin

In Oracle SQL / PLSQL a UNIQUE CONSTRAINT is single or group of column(s)/field(s) that can uniquely identify each record in a table.

Some of the column(s) / field(s) of unique constraint can have NULL values until the combination can uniquely identify each record of table.

Important points about UNIQUE CONSTRAINT in Oracle SQL / PLSQL:

  1. In Oracle SQL / PLSQL a UNIQUE CONSTRAINT can be created by using maximum of 32 columns / fields.
  2. A UNIQUE CONSTRAINT can be dropped, disabled and enabled in ALTER TABLE statement.

Syntax to DROP a UNIQUE CONSTRAINT in SQL / PLSQL is:

ALTER TABLE table_name
DROP CONSTRAINT constraint_name;

Example:

view source
print?
1ALTER TABLE employee
2DROP CONSTRAINT employee_pk;

The above statement will drop the unique constraint ‘employee_pk’ from the ‘employee’ table.


Disable a UNIQUE CONSTRAINT.

If we do not wish to delete the unique constraint as we may need the same in future but for some time we want the unique constraint not to function, then we can disable the unique constraint

Syntax for disabling the unique constraint in Oracle SQL / PLSQL is:

ALTER TABLE table_name
DISABLE CONSTRAINT constraint_name;

Example:

view source
print?
1ALTER TABLE employee
2DISABLE CONSTRAINT employee_pk;

Here in the above ALTER statement we have disabled the UNIQUE CONSTRAINT ‘employee_pk’ on the ‘employee’ table.


Enabling a UNIQUE CONSTRAINT

We can enable a unique constraint that has been disabled earlier, the syntax for enabling a unique constraint in Oracle SQL / PLSQL is:

ALTER TABLE table_name
ENABLE CONSTRAINT constraint_name;

Example:

view source
print?
1ALTER TABLE employee
2ENABLE CONSTRAINT employee_pk;

Here in the above statement we have enabled the unique constraint ‘employee_pk’ in ‘employee’ table using ALTER TABLE statement.


Filed Under: sql Tagged With: dropping disabling and enabling a unique constraint in oracle plsql, dropping disabling and enabling a unique constraint in oracle sql, how to use dropping disabling and enabling a unique constraint in oracle database query, how to use dropping disabling and enabling a unique constraint in oracle plsql, how to use dropping disabling and enabling a unique constraint in oracle sql, syntax and example of dropping disabling and enabling a unique constraint in oracle database query, syntax and example of dropping disabling and enabling a unique constraint in oracle plsql, syntax and example of dropping disabling and enabling a unique constraint in oracle sql, UNIQUECONSTRAINTPLSQL, using dropping disabling and enabling a unique constraint in oracle database query, using dropping disabling and enabling a unique constraint in oracle plsql, using dropping disabling and enabling a unique constraint in oracle sql

Copyright © 2025 · Parallax Pro on Genesis Framework · WordPress · Log in