Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 Oracle PL/SQL: Unique Constraint Jump to:  
Category: >> Oracle PL/SQL >> Unique Constraint Bookmark and Share

<< lastnext >>

Snippet Name: Unique Constraint

Description: A unique constraint is a single field or combination of fields that uniquely defines a record. Some of the fields can contain null values as long as the combination of values is unique.

- In Oracle, a unique constraint can not contain more than 32 columns.

- A unique constraint can be defined in either a CREATE TABLE statement or an ALTER TABLE statement.

Note that Oracle does not permit you to create both a primary key and unique constraint with the same columns.

Also see:
» Check Constraint - Create
» Primary Key Constraint
» Foreign Key Constraints
» Current_timestamp
» Deferring Constraint Checking
» Add Primary Key Constraint example
» Constraint Checks
» Add constraint example

Comment: (none)

Language: PL/SQL
Highlight Mode: PLSQL
Last Modified: March 07th, 2009

CREATE TABLE table_name
(column1 datatype NULL/NOT NULL,
column2 datatype NULL/NOT NULL,
...
CONSTRAINT constraint_name UNIQUE (column1, column2, . column_n)
);
 
 
-- For example:
 
ALTER TABLE ELIGIBILITY_SUMMARIES 
ADD (CONSTRAINT ESMY_ESMY2_UK UNIQUE (PLAN_IDENTIFIER,
                                      PCP_ID,
                                      SUMMARY_MONTH)
USING INDEX
PCTFREE 10
)
/
 


Free
Oracle Magazine
Subscriptions
and Oracle White Papers


SQL University.net courses meet the most demanding needs of the business world for advanced education in a cost-effective manner. SQL University.net courses are available immediately for IT professionals and can be taken without disruption of your workplace schedule or processes.

Compared to traditional travel-based training, SQL University.net saves time and valuable corporate resources, allowing companies to do more with less. That's our mission, and that's what we deliver.

Click here to find out more
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 80 users online    © 2009 psoug.org

PSOUG LOGIN
Username: 
Password: 
Forgot your password?