473,398 Members | 2,088 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Index / Primary Key

Is that true that one table can only have one clustered index? The
column with clustered index will be sorted physically, is that true?
The column with non-clustere index will not be sorted physically, is
that true?

Also, is primary key clustered index by default?

Thanks!
Nov 12 '05 #1
5 5344
"Jerry" <je*********@hotmail.com> wrote in message
news:8c**************************@posting.google.c om...
Is that true that one table can only have one clustered index? The
column with clustered index will be sorted physically, is that true?
The column with non-clustere index will not be sorted physically, is
that true?

Also, is primary key clustered index by default?

Thanks!


A very common point of confusion.

All indexes are sorted in the exact order of the index. By designating a
clustering index, you are specifying the order of the rows in the associated
table (the order of which DB2 tries to maintain during an insert and after a
reorg of the table). So by that definition, there can only be one clustering
index per table.

In DB2 for LUW, there is no clustering index by default. In DB2 for z/OS,
the first index defined is the clustering index unless another index is
explicitly defined as the clustering index.
Nov 12 '05 #2
Ian
Mark A wrote:
"Jerry" <je*********@hotmail.com> wrote in message
news:8c**************************@posting.google.c om...
Is that true that one table can only have one clustered index? The
column with clustered index will be sorted physically, is that true?
The column with non-clustere index will not be sorted physically, is
that true?

Also, is primary key clustered index by default?

Thanks!

A very common point of confusion.

All indexes are sorted in the exact order of the index. By designating a
clustering index, you are specifying the order of the rows in the associated
table (the order of which DB2 tries to maintain during an insert and after a
reorg of the table). So by that definition, there can only be one clustering
index per table.


It is true that a table can have only 1 clustering index.

HOWEVER:

DB2 UDB V8.x for LUW has a new feature called multi-dimensional
clustering (MDC) which allows you to define multiple dimensions
(groups of columns) and DB2 will *guarantee* that the table is
clustered along each dimension.

This feature effectively allows you to have more than one clustering
index (but the physical implementation is completely different).


Nov 12 '05 #3
"Ian" <ia*****@mobileaudio.com> wrote in message
news:42**********@newsfeed.slurp.net...

HOWEVER:

DB2 UDB V8.x for LUW has a new feature called multi-dimensional
clustering (MDC) which allows you to define multiple dimensions
(groups of columns) and DB2 will *guarantee* that the table is
clustered along each dimension.

This feature effectively allows you to have more than one clustering
index (but the physical implementation is completely different).

No, there is only one MDC per table.

Ian: Do you let you children play with matches?
Nov 12 '05 #4
dc
"Mark A" <no****@nowhere.com> wrote in
news:AL********************@comcast.com:
"Jerry" <je*********@hotmail.com> wrote in message
news:8c**************************@posting.google.c om...
Is that true that one table can only have one clustered index? The
column with clustered index will be sorted physically, is that true?
The column with non-clustere index will not be sorted physically, is
that true?

Also, is primary key clustered index by default?

Thanks!


A very common point of confusion.

All indexes are sorted in the exact order of the index. By designating
a clustering index, you are specifying the order of the rows in the
associated table (the order of which DB2 tries to maintain during an
insert and after a reorg of the table). So by that definition, there
can only be one clustering index per table.

In DB2 for LUW, there is no clustering index by default. In DB2 for
z/OS, the first index defined is the clustering index unless another
index is explicitly defined as the clustering index.


One slight nuance on the stmt "In DB2 for z/OS, the first index defined
is the clustering index unless another index is explicitly defined as the
clustering index. "

It is technically the oldest remaining index on the table that is the
default cluster index. Meaning if you create a table withi idx01 and
dont specify a CI and then add idx02 at a later date, the clustering is
on idx01. If you subsequently drop idx01 and re-create it and don't
specify idx01 as the CI then the data will be clustered on idx02.

This sometimes burns people.
Nov 12 '05 #5
"dc" <no**@non.com> wrote in message
news:Xn*************************@199.45.49.11...

One slight nuance on the stmt "In DB2 for z/OS, the first index defined
is the clustering index unless another index is explicitly defined as the
clustering index. "

It is technically the oldest remaining index on the table that is the
default cluster index. Meaning if you create a table withi idx01 and
dont specify a CI and then add idx02 at a later date, the clustering is
on idx01. If you subsequently drop idx01 and re-create it and don't
specify idx01 as the CI then the data will be clustered on idx02.

This sometimes burns people.


Clustering indexes should be explicitly defined, which can be done with an
alter in DB2 for z/OS (anyone in Toronto listening?).

The biggest problem with not explicitly defining the clustering index is
that you will often have the index for the PK as the clustering index by
default, since it is often the first index created. But if the PK is a
single column, then it is usually a very poor choice for the clustering
index.
Nov 12 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Tuhin Kumar | last post by:
Hi, Oracle give the error ORA-01418 when I try to do the following; Create unique index t1_pk on TABLE1(EntryId DESC) ; If the I try to add primary key Contraint using the above index t1_pk...
25
by: sql_server_2000_user | last post by:
Hi, I have a table with about 305 million rows, and a composite primary key that consists of an ascending int and an ascending varchar(18), which is typically of length 13. Even if all the keys...
6
by: christopher.secord | last post by:
Is there any advantage to doing this: ALTER TABLE testtable ADD CONSTRAINT PK_sysUser PRIMARY KEY NONCLUSTERED (UserID) WITH FILLFACTOR = 100, CONSTRAINT IX_sysUser UNIQUE NONCLUSTERED...
4
by: deko | last post by:
I have a Make Table query that creates a fairly large table. The Make Table query populates the new table with one AutoNumber field (which is taken form another unrelated table as part of the...
10
by: deko | last post by:
I understand it's possible to make a composite Primary Key by holding down the control key and selecting multiple fields, then right-clicking and selecting Primary Key. But I've heard that's not a...
15
by: rAinDeEr | last post by:
Suppose i have a table which holds thousands of records with the following structure CREATE TABLE "test "."T_CNTRY" ( "CNTRY_CDE" CHAR(2) NOT NULL , "CNTRY_NAME" VARCHAR(50) ) and i have...
10
by: Laurence | last post by:
Hi there, How to differentiate between unique constraint and unique index? These are very similar but I cannot differentiate them? Could someone give me a hand? Thanks in advance
3
by: vj_dba | last post by:
Hi Group, I have a Primary key in my table. It's clear Primary key wont allow duplicates, this primary key creates one index for retrival. Suppose if my table is having a Unique index also....
4
by: codefragment | last post by:
Hi I thought that given a table with an index, primary key and clustered index any non clustered index look ups would go via the clustered index and the primary key is irrelevant? (sql server...
10
by: Ian | last post by:
Henry J. wrote: MDC *guarantees* clustering, whereas a table with a clustering index will eventually require maintenance (a.k.a. reorg) to maintain the cluster ratio. That's not to say that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.