SQL UNIQUE

UNIQUE constraint uniquely identifies each row in a table.

You can have multiple UNIQUE constraints in different columns of a table.

There are several different forms of syntax as the database system used

SQL UNIQUE Example for MySQL database

CREATE TABLE people { id int NOT NULL, name varchar (255) NOT NULL, surname varchar (255) NOT NULL, nickname varchar (255), UNIQUE (id) }

The above statement creates the table 'people' with 4 columns where the column 'id' has a different value for each row of the table.

If we try to insert a row with an 'id' that already exists, we will fail, and we will not insert it.

Example SQL UNIQUE for Oracle databases, SQLSERVER, ACCESS

CREATE TABLE people { id int NOT NULL UNIQUE, name varchar (255) NOT NULL, surname varchar (255) NOT NULL, nickname varchar (255) }