What is the difference between primary key & unique index ?

Answers were Sorted based on User's Feedback



What is the difference between primary key & unique index ?..

Answer / shankar

Primary Key cannot have NULL values in it wherein an
UNIQUE index can have one NULL value in it.

Is This Answer Correct ?    37 Yes 3 No

What is the difference between primary key & unique index ?..

Answer / mani

Primary key can be defined only one for a table whereas
number of unique indexes can be defined for a table.

primary key can not have null values but unique can have
null values and to remind one null value can never be equal
to another null value.

Is This Answer Correct ?    23 Yes 4 No

What is the difference between primary key & unique index ?..

Answer / uddipto banerji

1. Primary Key is a column or a set of columns that uniquely identifies a row.Its purpose RECORD UNIQUENESS
2. Primary Key will not allow duplicate values.
3. Primary Key will not allow null.
4. Primary Key is not compulsory but recommended.
5. Primary Key helps to identify one record from another.
6. Only One Primary Key is allowed per table.
7. Unique Indexes is created automatically if there is Primary Key.
8. One table can combine upto 16 columns in a Composite Primary Key.
9. A table can have more than one Unique Key which is not possible in a Primary Key.

Is This Answer Correct ?    10 Yes 2 No

What is the difference between primary key & unique index ?..

Answer / palash ghosh

1)Primary key creates an implicit culstered index on a
table, unique key does not create any implicit index.
2)Columns defined as primary key does not allow null values,
where as columns defined as unique can allow null values.
3)A table can have just one primary key (can be a composite
key) where as there can be multiple unique columns (keys).
4)Primary key is a unique key with the above mentioned
features.

Is This Answer Correct ?    9 Yes 1 No

What is the difference between primary key & unique index ?..

Answer / mehdee

- Each primary key must associate with a unique index, but
unique index dose not have to associate to the primary key.

Is This Answer Correct ?    6 Yes 3 No

What is the difference between primary key & unique index ?..

Answer / s

Primary Key uniquely identifies the record and the UNIQUE
index on the primary key ensures that no duplicates values
will be stored in the table.

Is This Answer Correct ?    16 Yes 14 No

Post New Answer

More DB2 Interview Questions

Can you define an Index if the table size less than 10 PAGES?

1 Answers   IBM,


What action db2 takes when a program aborts in the middle of a transaction?

0 Answers  


What are host variables in db2?

0 Answers  


What is the purpose of the WHENEVER statement?

1 Answers  


In db2, how do you insert multiple rows in 1 query using a.) Cursors, b.) Normal query?? Give syntax for both.

5 Answers   CTS,






in my table i will update only 100 record among 1000 records i need to display recently updated record'.....can u tell me where those records are stored how can i display those records...?if there is any sql query pls let me know....?

3 Answers   Infosys,


Define sqlca.

0 Answers  


Q1. How will you use two different DB2 qualifiers in a single COBOL program? Suppose we have 2 tables EMP1 and EMP2 with same structure defined in two different DB2 qualifiers QUAL1.EMP1 and QUAL2.EMP2 now during first 15 days we want to use QUAL1.EMP1 and rest of the days QUAL2.EMP2  how will we do this.  We can create a single program and a single load for this program. 

2 Answers   RBS,


SET is the ANSI standard for variable assignment, SELECT is not. SET can only assign one variable at a time, SELECT can make multiple assignments at once. If assigning from a query, SET can only assign a scalar value. If the query returns multiple values/rows then SET will raise an error. SELECT will assign one of the values to the variable and hide the fact that multiple values were returned (so you'd likely never know why something was going wrong elsewhere - have fun troubleshooting that one) When assigning from a query if there is no value returned then SET will assign NULL, where SELECT will not make the assignment at all (so the variable will not be changed from it's previous value) As far as speed differences - there are no direct differences between SET and SELECT. However SELECT's ability to make multiple assignments in one shot does give it a slight speed advantage over SET.

0 Answers  


What is bind and rebind in db2?

0 Answers  


What is a DB2 catalog?

2 Answers  


How we create a tables in db2,what is the process/syntax to create a table with example plz?

2 Answers  


Categories