Difference between primary key and unique key ?

Answers were Sorted based on User's Feedback



Difference between primary key and unique key ?..

Answer / alok

There is only two Point:
1. The not null constraint is by default added to primary key, it means, primary key attribute cannot accept null values, whereas, the attribute declared as unique can accept null values. It is the major difference between the two.
2. Secondly, we can have only one primary key in a relation, whereas, multiple attributes can be declared unique at the same time.

Is This Answer Correct ?    0 Yes 0 No

Difference between primary key and unique key ?..

Answer / yjreddy

primary key doesnt allow duplicates and null values
unique key allows null value only once
and more over
when you applying primary key by default clustered index is created on that table
when u applying unique key non clustered index is created on that table.
so primary key can be allowed only once(1) and unique u can apply more
than one on a single table(249)

Is This Answer Correct ?    0 Yes 0 No

Difference between primary key and unique key ?..

Answer / madhumita majhi

In SQL both primary key and unique enforce uniqueness of
the column on which they are defined. But by default
primary key creates a clustered index on the column, where
are unique creates a non-clustered index by default.
Another major difference is that, primary key doesn't allow
NULLs, but unique key allows one NULL only.

Unique Key: Identify the row by uniquely, means if you are
inserting a records into the table suppose you already
inserted a record with ID 101 and another record you are
inserting with the same ID then it will give an error
(unique key voilation).

Prmary Key:Once you define a primay key on a particular
column then a column become a mandatory field.That means
you need to insert something on it, you can not leave as a
blank otherwise it will give an error as primary key
voilation.

Is This Answer Correct ?    0 Yes 0 No

Difference between primary key and unique key ?..

Answer / rakesh dwivedi

1.Primary key can not have null.Instead of it unique can have null at lest single time null.
2 In a table only one primary key exist.Unique can be multiple in table.

Is This Answer Correct ?    0 Yes 0 No

Difference between primary key and unique key ?..

Answer / rubiya george

Primary Key Vs Unique key
1.Each table having 1. contain many UNIQUE KEYS.
only one PRIMARY KEY.
2.Primary key not accepts 2.Unique Key accepts null
null values values

Is This Answer Correct ?    0 Yes 0 No

Difference between primary key and unique key ?..

Answer / anand b

Primary Key : Is an identity of a row, Only one primary key per table, No duplicate values allowed, & No NULL values are allowed.

Unique Key : Its values are unique, It can contain any number of NULL values unless combination is going to be unique.

Is This Answer Correct ?    1 Yes 2 No

Difference between primary key and unique key ?..

Answer / sonali.s

column having primary key constraint should not contain
null values.

column having unique key constraint can contain null values.

Is This Answer Correct ?    1 Yes 2 No

Difference between primary key and unique key ?..

Answer / mohammad ali

-The column holding the primary key constraint cannot accept
null values.whereas colum holding the unique constraint can
accept null values.
-We can declare only one primary key in a table
but a table can have multiple unique key
-Clustered index is created on Primary key constraint and
non clustered unique indexes is created on Unique key constraint.
-Primary key columns automatically become NOT NULL (unique
keys can contain nulls).

Is This Answer Correct ?    1 Yes 2 No

Difference between primary key and unique key ?..

Answer / chintan desai

Primary key don't have any null value, each table have only
one primary key. Not support duplicate value.

Unique key is uniquely identify, more then one unique key
allow in table.

Here the main different is what primary key do not have any
null value where unique key have only one null value.

Ex: here t1 is the name of table which have two field id and
name. here id is identify as a unique key then unique key's
null value look like under bellow:

1 chintan
NULL komal
2 ck
NULL NULL

Is This Answer Correct ?    2 Yes 3 No

Difference between primary key and unique key ?..

Answer / mudigouda patil

PRIMARY KEY
1)TABLE CAN NOT HAVE MORE THAN ONE PRIMARY KEY.
2)PK DOES NOT ALLOW NULL VALUES.
UNIQUE KEY
1)TABLES CAN HAVE MORE THAN ONE UNIQUE KEY.
2)UNIQUE KEY ALLOWS NULL VALUES.

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More Oracle General Interview Questions

What is the data type of dual table?

0 Answers  


what is difference between cartesian join & cross join even they give same result?

4 Answers   Bank Of America,


What is oracle used for?

0 Answers  


DBMS vs. RDBMS

2 Answers   TCS,


What are the different types of modules in oracle forms?

0 Answers  






acname actype amount ac1 credit 300 ac2 credit 4000 ac1 debit 4000 ac2 debit 455 ac1 credit 500 how to get sum of credit and sum of debit for each account

2 Answers   Polaris,


What is STATSPACK tool?

3 Answers   Wipro,


What are the factors causing the reparsing of SQL statements in SGA?

2 Answers  


How to get a list of all tables in the database?

1 Answers  


What is the Extension of Oracle Database? As extension of Access Database is .mdb

2 Answers  


Explain do view contain data?

0 Answers  


How to use "in" parameter properly?

0 Answers  


Categories
  • Oracle General Interview Questions Oracle General (1789)
  • Oracle DBA (Database Administration) Interview Questions Oracle DBA (Database Administration) (261)
  • Oracle Call Interface (OCI) Interview Questions Oracle Call Interface (OCI) (10)
  • Oracle Architecture Interview Questions Oracle Architecture (90)
  • Oracle Security Interview Questions Oracle Security (38)
  • Oracle Forms Reports Interview Questions Oracle Forms Reports (510)
  • Oracle Data Integrator (ODI) Interview Questions Oracle Data Integrator (ODI) (120)
  • Oracle ETL Interview Questions Oracle ETL (15)
  • Oracle RAC Interview Questions Oracle RAC (93)
  • Oracle D2K Interview Questions Oracle D2K (72)
  • Oracle AllOther Interview Questions Oracle AllOther (241)