Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Neha SharmaRank #569 · 4.3K reputationPosted Jan 2, 2013, 10:03 PM EST
Satyapriya NayakRank #47 · 31.5K reputationPosted Dec 26, 2012, 12:48 AM EST
http://www.1keydata.com/sql/sql-unique.html
sathish kumar115 reputationPosted Jan 2, 2013, 8:17 PM EST
When u want to have one NULL values in ur data u can use UNIQUE KEY . Because Unique key can accept one NULL value.
But in t case of Primay key, it doesnt accept any NULL value. So when u dont want being entered NULL values in ur table u can use PRIMARY KEY..
Hope this will be helpful for u.....
Jignesh TrivediRank #16 · 50.3K reputationPosted Jan 2, 2013, 8:56 PM EST
Both Primary and Unique Keys are enforce uniqueness of the column.
Primary Key creates clustered index by default and doesn't allow nulls.
Unique Key creates non-clustered index by default and allows only one null value.
you can choose any one from PK and Unique key but as you know table contain only one PK so if you required Uniquness on other column also then you may use Unique key on that column.
hope this will help you.
Vithal WadjeRank #19 · 47.2K reputationPosted Jan 2, 2013, 11:41 PM EST
my question is that in which situation i need to allow one null value that is which situation i need a uniqe key to apply...
any real time example you can explain
Neha SharmaRank #569 · 4.3K reputationPosted Jan 2, 2013, 11:47 PM EST
satish babuRank #2,232 · 629 reputationPosted Jan 4, 2013, 1:36 AM EST
Vithal WadjeRank #19 · 47.2K reputationPosted Jan 4, 2013, 6:15 PM EST
Vishnujeet KumarRank #1,019 · 1.9K reputationPosted Jan 4, 2013, 7:10 PM EST
One more important scenario, if you want set references as foreign key ,then you have only one option first create primary key .
Neha SharmaRank #569 · 4.3K reputationPosted Jan 4, 2013, 8:02 PM EST
Ashutosh SharmaRank #6,801 · 256 reputationPosted Jan 12, 2013, 10:06 PM EST