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 > To find Partition column in a table

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-02-11, 01:28
Sajeev Sajeev is offline
Registered User
 
Join Date: Aug 2011
Posts: 10
To find Partition column in a table

How can we find the column which is used as a partion key for a specified table?
Is there any query?

Last edited by Sajeev; 08-02-11 at 02:26.
Reply With Quote
  #2 (permalink)  
Old 08-02-11, 02:58
przytula_guy przytula_guy is offline
Registered User
 
Join Date: Apr 2006
Location: Belgium
Posts: 1,159
depending if table partitioning or db partitioning has been used
go to : SYSCAT.PARTITIONMAPS catalog view
and see for partitioning key : in sycat.partitionmaps datapartitions.....
__________________
Best Regards, Guy Przytula
Database Software Consultant
DB2 UDB LUW Certified V7-V8-V9-V9.7 DB Admin - Dprop..
Information Server Datastage Certified
http://www.infocura.be
Reply With Quote
  #3 (permalink)  
Old 08-02-11, 03:46
prakash56 prakash56 is offline
Registered User
 
Join Date: Jan 2004
Location: UK
Posts: 11
db2 "select colname from syscat.columns where PARTKEYSEQ=1 and tabname='<TABLENAME>'"
Reply With Quote
  #4 (permalink)  
Old 08-02-11, 05:21
Sajeev Sajeev is offline
Registered User
 
Join Date: Aug 2011
Posts: 10
@prakash

Thanks prakash , I got what I expected.
Reply With Quote
  #5 (permalink)  
Old 08-02-11, 05:22
Sajeev Sajeev is offline
Registered User
 
Join Date: Aug 2011
Posts: 10
i want the column name
Reply With Quote
  #6 (permalink)  
Old 08-02-11, 06:29
dr_te_z dr_te_z is offline
Registered User
 
Join Date: Jan 2009
Location: Zoetermeer, Holland
Posts: 555
Look at db2look
Reply With Quote
  #7 (permalink)  
Old 04-23-12, 11:17
Rediranch Rediranch is offline
Registered User
 
Join Date: Mar 2003
Posts: 3
Quote:
Originally Posted by prakash56 View Post
db2 "select colname from syscat.columns where PARTKEYSEQ=1 and tabname='<TABLENAME>'"
That is not the partition key name, it might be an index or primary key. I ran this on a table where I know the partition column name, and it does not return the partitioned column name.

PARTKEYSEQ = The column's numerical position within the table's distribution key; 0 or the null value if the column is not in the distribution key. Null for columns of subtables and hierarchy tables.

To find the partitioned column name used -

-- identify column names used in partitions
select tabschema
,tabname
,cast(datapartitionexpression as varchar(100)) part_column
from syscat.datapartitionexpression
where tabschema = 'SCHEMA_OWNER'
order by 1,2
;

Last edited by Rediranch; 04-23-12 at 11:51.
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