SQL> -- A unique constraint can be extended over multiple columns:
SQL>
SQL> create table myTable (
2 a number,
3 b number,
4 c number,
5 unique (a,b)
6 );
Table created.
SQL>
SQL> insert into myTable values (4, 3, 5);
1 row created.
SQL> insert into myTable values (4, 1, 5);
1 row created.
SQL> insert into myTable values (4, 2, 5);
1 row created.
SQL> insert into myTable values (4, 3, 5);
insert into myTable values (4, 3, 5)
*
ERROR at line 1:
ORA-00001: unique constraint (SYS.SYS_C004360) violated
SQL>
SQL> select * from myTable;
A B C
---------- ---------- ----------
4 3 5
4 1 5
4 2 5
SQL>
SQL> drop table myTable;
Table dropped.
SQL>
SQL>
|