SQL UNIQUE

SQL UNIQUE uniquely identifies each record in a database table.

The UNIQUE and PRIMARY KEY constraints both provide a guarantee for uniqueness for a column or set of columns.

A PRIMARY KEY constraint automatically has a UNIQUE constraint defined on it.

We can have many UNIQUE constraints in a table, but only one PRIMARY KEY .

Example

mysql> CREATE TABLE  `new_users` (`id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, PRIMARY KEY (`id`), UNIQUE (Id));
Query OK, 0 rows affected (0.10 sec)