Oracle sql - can we have 2 unique column in the same table -


In my web application, I have a customer name and a customer phone number. I should allow the same phone number multiple times. But I should not allow the same client name to be entered several times. If there is already a customer named 'Sean Patrick' with mobile number '6039274849' in the future, I should not run a new user with the same name ('Sean Patrick') in the future.

  Customer table column CUSTOMER_ID unique customer name CUST_MOB_NUMBER   

>

I am using Spring Ro I Use the HibernatePAP (Aspectage Code) for the related accessories.

Can someone explain how to do this so far I have been thinking of making 2 columns uike. Is there any way to make 2 columns unique in any way?

Assume that understanding the requirements (it really does not make sense to say that two customers have the same Will not be named - There are so many John Smith in the world). And people often have many mobile numbers.

You can declare as unique as both customer_id and customer_name (though customer_id are almost sure Form should be declared as primary key, not exclusive only)

  create customer (customer_id number primary key, customer_name VARCHAR2 (100) unique, cust_mob_number VARCHAR2 (20));   

You declare a combination of two columns as unique

  create a customer (customer_id number primary key, customer_name VARCHAR2 (100), Cust_mob_number VARCHAR2 (20), contract uk_name_and_number UNIQUE (customer_name, customer_mob_number));    

Comments