View previous topic :: View next topic
|
Author |
Message |
chandrasekhar
New User
Joined: 29 Sep 2004 Posts: 35 Location: bangalore
|
|
|
|
q1. Can a table have more then one primary key.
q2
. What is the diff. between unique key and primary key.
q3. is it necessary to creat a index for every table.
q4.Can a table resides under more then one tablespace . |
|
Back to top |
|
|
janardhana Reddy
New User
Joined: 20 Oct 2004 Posts: 17 Location: Bangalore
|
|
|
|
Hi
1) Ans. One table should have only one primary key.
2) Ans. The main difference b/t unique key and primary key is null value.
Unique key may have null value.
3) Ans. If no index exists means you will not able execute some functions like count etc. To create path you need the index. If no index means there is no difference between flat file and database file..
4) no table can reside in more than one table space. |
|
Back to top |
|
|
khamarutheen
Active Member
Joined: 23 Aug 2005 Posts: 677 Location: NJ
|
|
|
|
hi frnd,
one more thing is that unique key will have only one null value i think so.
but primary key will not have that too.
and if the primary key is created then u should need the unique index such that to activate the primary key. |
|
Back to top |
|
|
priya
Moderator
Joined: 24 Jul 2003 Posts: 568 Location: Bangalore
|
|
|
|
Yes, you can have more than one columns as primary key. It's called as partial key. |
|
Back to top |
|
|
jontyjun
New User
Joined: 12 Sep 2006 Posts: 12 Location: India
|
|
|
|
Hi Janardhana Reddy,
This is in regard to your answer: "3) Ans. If no index exists means you will not able execute some functions like count etc. To create path you need the index. If no index means there is no difference between flat file and database file.."
For Count You dont need an index at all... Verified it just now..
Regards,
Arjun. |
|
Back to top |
|
|
stodolas
Active Member
Joined: 13 Jun 2007 Posts: 632 Location: Wisconsin
|
|
|
|
1) No - as has been stated but a primary key can be multiple columns
If you define a primary key with multiple columns, when you reference only one of those columns it is called a partial key
2) Primary key should be defined as the most commonly accessed key
Unique keys are ususually defined on columns other than the primary key. Think of them as alternate indexes on a VSAM with a uniqueness contraint. Although I have never heard them called Unique keys, usually they are called indexes.
3) No - but it will help performance |
|
Back to top |
|
|
|