I know that using the following codes will make each column have unique values, but what if I want a full name to be unique?
CREATE TABLE people (first_name varchar2(32) unique,
last_name varchar2(32) unique);
this will make each attribute unique on its own, but I need to make them both together unique, like If I have a name "James Smith", I don't want this name to be repeated again, but its ok if there was a "James Sunderland" guy.
Define the UNIQUE constraint on the combination of the two columns:
CREATE TABLE people
( first_name varchar2(32) ,
last_name varchar2(32) ,
UNIQUE ( first_name, last_name )
) ;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With