A UNIQUE KEY constraint imposes a unique column value rule on a column or set of columns. This rule ensures that all values in the column or set of columns are unique and the values of the column or set of columns in any two rows of the table are not duplicated.
The following example shows the features of the syntax of a UNIQUE KEY constraint:
obclient> CREATE TABLE t1(c1 INT, c2 INT, CONSTRAINT t1_uk_c1_c2 UNIQUE(c1, c2));
Query OK, 0 rows affected
obclient> INSERT INTO t1 VALUES(1, 1);
Query OK, 1 row affected
obclient> INSERT INTO t1 VALUES(1, 1);
ORA-00001: unique constraint '1-1' for key 'T1_UK_C1_C2' violated
obclient> INSERT INTO t1 VALUES(null, 1);
Query OK, 1 row affected
obclient> INSERT INTO t1 VALUES(null, 1);
ORA-00001: unique constraint 'NULL-1' for key 'T1_UK_C1_C2' violated
obclient> INSERT INTO t1 VALUES(null, null);
Query OK, 1 row affected
obclient> INSERT INTO t1 VALUES(null, null);
Query OK, 1 row affected
You can insert any number of rows into the customer table. However, the UNIQUE KEY constraint requires that the combination of the area code and telephone number in each row must be unique in the table. This prevents unintentional duplication of telephone numbers.