Home

The Uniqueness of a Column

 

Introduction

During data entry, the user is allowed to type the same value in the same fields of two different records. For example, it is not unusual for two people to have the same last name. In some other cases, you may want each record to have a different value for a particular field. For example, a company may not allow two employees to have the same employee number or the same security numbers, just like two cars should not have the same tag number in the same state. To communicate this, on the right side, type the UNIQUE keyword.

Here is an example:

CREATE TABLE Employees
(
    EmployeeNumber integer UNIQUE,
    FirstName Text(50) NULL,
    LastName Text(50) NOT NULL,
    Title varchar(100) NULL,
    HourlySalary Currency
);

When performing data entry, you must make sure the user enters a value for that column and no other record can have that same value. Here is an example:

INSERT INTO Employees
VALUES(206804, "Anne", "Simms", "Sales Associate", 24.50);

Here is another example:

INSERT INTO Employees
VALUES(825502, "Carla", "Desmonds", "Regional Manager", 44.50);

If you (the user) try (tries) adding a record that has a value that exists already, you (the user) would receive an error:

 


Home Copyright © 2008-2012 FunctionX