If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Clustering Index

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-22-05, 05:31
AnilKale AnilKale is offline
Registered User
 
Join Date: Feb 2005
Posts: 118
Clustering Index

Hi All !

A CREATE TABLE....PRIMARY KEY... done on UDB DB2 on Windows, automatically creates a unique index on the primary key. How can you make the primary index a clustered index ?
In the os/390 world, the CREATE TABLE would put the table in a incomplete state. It would be marked as usable only after your create the unique index on the primary key cols. Since it is a seperate create unique index DDL, it was easy to specify the CLUSTER option.


Anil
Reply With Quote
  #2 (permalink)  
Old 02-22-05, 06:16
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
You would do the following:

1. Create the table without RI (no primary key)
2. Create a unique index on the primary key columns and make it clustered.
3. Create the Primary Key (DB2 will use the index already created)
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #3 (permalink)  
Old 02-22-05, 06:22
grofaty grofaty is offline
Registered User
 
Join Date: Jan 2003
Posts: 1,570
Hi,

1. create unique index schema.index_name on schema.table_name (col1, col2, etc) CLUSTER
2. alter table schema.table_name add primary key (col1,col2,etc)

Second command will return a warning. Ignore it!

Hope this helps,
Grofaty
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On