TechnoLearnAcademy

TECHNOLEARN

UNIQUE CONSTRAINT

A UNIQUE constraint is a database concept used to ensure that values in a particular column within a table are unique across all the rows in that table.
    • In a table, it is not allowed to have two rows with the same value in a specific column.
    • We can assign a unique constraint to each column of a table.

Example:

   Objective: In this example, we will assign a unique constraint to the emailaddress column.
                      CREATE TABLE TBL_EMP(
                                                              Ecode varchar(20) Primary key,
                                                              Name varchar(20),
                                                              Emailaddress varchar(20),
                                                              Department varchar(20) UNIQUE,
                                                              Salary int
                                                                              );
Scroll to Top