When we can declare a column as Unique and Not Null both at the same time. What is the use pf Primary Key then?

Showing Answers 1 - 21 of 21 Answers

Avinash Byalihal

  • Aug 8th, 2006
 

Declare that column as UNIQUE and add constraint as NOT NULL.Hope this helps u.

  Was this answer useful?  Yes

Rama Krishna

  • Aug 9th, 2006
 

Hi Gupta!!

The Major Advantage of PKey is Its being INDEXED and the perofrmance going to increase..

Thanks&Regds

Ramki,

TCS,Dp,Hyd

Rajesh

  • Aug 11th, 2006
 

As per my knowledge is concerned..

if already you have created a primary key on one table and in that same table another column is there, which is also mandatory for you- in that context you have to use Unique key and add not null constraint.

Rajesh

  Was this answer useful?  Yes

Amlan sarkar

  • Aug 15th, 2006
 

Hi ,

The concept of adding an unique key and not null constraint to a column as well as adding as unique index to it , you will assume to get the  benefits  of adding an primary key to that column.

But use it for the purpose of referential integrity will not allow to do so.

That's what PK is so useful. You will use it for normalization purpose.

Hope things are clear now.

Regards

Amlan

vishalreddy

  • Aug 29th, 2006
 

this is not possible.

  Was this answer useful?  Yes

manohar

  • Sep 14th, 2006
 

hi,primary key is nothing but unique+not null+indexes......

  Was this answer useful?  Yes

chary

  • Jul 9th, 2007
 

Apart from null and not not null context, when both primary key and unique key uniquely identifies an row.... in a table, what is the major difference between them



waiting for reply......


Thanks

  Was this answer useful?  Yes

Parmita Mallick

  • Sep 7th, 2011
 

unique key are also indexed. PRIMARY KEY is clustered index whereas UNIQUE KEY is non clustered.

  Was this answer useful?  Yes

z_ashwini

  • Jan 13th, 2012
 

Eg:

Consider table emp with EMP_ID,EM|NAME,ADD columns

You can define the column e_name as Unique constraint.

DECLARE
e_name number(10) NOT NULL;
BEGIN
...
..
END:

Primary key cannot have NULL values and is unique.
One table can have single primary key.
Suppose you have already defined EMP_ID as primary_key in the previous example and if you want NOT NULL and Unique values then you can use the above alternative.

Best Regards,
Ashwini Likhite

  Was this answer useful?  Yes

Vinod Tuteja

  • Jun 14th, 2013
 

Main Difference : Referential
Index is created in both Cases (Unique and Primary key Constraint )

But can't references Columns with combination of UNIQUE and NOT NULL. Like in Primary key ,we Can references primary key to make foreign key constraint .

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions