RSS Feed

UNIQUE Constraint

SQL UNIQUE Constraint

SQL UNIQUE Constraint indicates that a column or set of columns should contain unique values, meaning that no two values of "Ename" column (if Ename has a UNIQUE constraint) should be same.

Example 1 of SQL UNIQUE Constraint

CREATE TABLE Sells (
  bar   CHAR(20),
  beer VARCHAR(20),
  price REAL,
  UNIQUE(bar,beer)
 );

Example 2 of SQL UNIQUE Constraint

CREATE TABLE Sells (
  bar CHAR(20)   UNIQUE,
  beer VARCHAR(20)  UNIQUE,
  price REAL
 );

Both the above example are different.

Also See:
Difference between Unique & Primary key.

No comments:

Post a Comment