java2db

Sql UNIQUE constraint on table column



If any column/columns  in the table define with UNIQUE constraint , the specified column does not allow same values(duplicate values). Possible to define UNIQUE constraint to more than one column.The UNIQUE key made up of a single column can contain nulls.

 

UNIQUE constraint  Restrictions :
UNIQUE constraint  A UNIQUE key column cannot be of data type LONG or LONG RAW.
UNIQUE constraint  A composite UNIQUE key cannot have more than 32 columns.
UNIQUE constraint  It is not possible to declare the same column or combination of columns as both a UNIQUE key and a

…..PRIMARY key.
UNIQUE constraint  None of the columns in the UNIQUE key can have data type TIMESTAMP WITH TIME ZONE.However ,

…..the UNIQUE  key can contain a column of TIMESTAMP WITH LOCAL TIME ZONE.

 

UNIQUE constraintUNIQUE constraint at column level :

Specify the  constraint along with  the column/columns declaration .

 

UNIQUE constraint UNIQUE constraint at table level :

Declare the constraint  at the end of the table .See the example sql statement below .

 

UNIQUE constraint UNIQUE constraint with ALTER:

Use ALTER TABLE  command to add  an UNIQUE constraint, if the table already exists.

 

UNIQUE constraintDrop UNIQUE constraint :

Drop the constraint with it’s name.

 

UNIQUE constraintComposite UNIQUE key :

A table may have many UNIQUE keys.If the UNIQUE constraint is defined in more than one column (combination of columns), it is said to be composite UNIQUE key.




Related Posts :
Sql FOREIGN KEY constraint on table column
Sql CHECK constraint on table column
Sql NOT NULL constraint on table column
Sql PRIMARY KEY constraint on table column
Sql full outer join on tables with an example
Sql right outer join on tables with an example
Sql left outer join on tables with an example
Sql inner join on tables with an example
   [will not be published]



^ <