So many people asked me this question; In many interviews also I faced this question.Let’s we have a look into this.
- Primary Key and Unique key (both) uniquely identifies a row.
- Unique Key Allows 1 null column, where are Primary key will not allow null values.
- As per the DBA’s Point of view, Primary key creates a clustered index,where unique key creates non-clustered index.
I hope every one like this article.Please make some comments .
Two days before, One of my colleague who is a .Net Programmer named Preethy Kamath (an enthusiastic lady)came and asked me what is the difference between char and varchar. I explained her in detail about the difference and that is what I am going to explain here.
It is fixed length non-Unicode character data with a length from 1 to 8000 bytes.
It is variable length non-unicode character data with a length from 1 to 8000 bytes.The maximum storage size is 2^31-1 bytes.
From the columns varchardatalength and Chardatalength we came to understand that the varchar takes only 3 character length(since it is variablelength) and Char takes 50 charlength(since it is fixed length).
Please be careful while choosing the data type during Database design .
I hope every one like this article,Heathly comments are welcomed.Thanks Preethi once again for this wonderful basic question.