Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2011
    Posts
    10

    Unanswered: 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 03:26.

  2. #2
    Join Date
    Apr 2006
    Location
    Belgium
    Posts
    2,514
    Provided Answers: 11
    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
    Good DBAs are not formed in a week or a month. They are created little by little, day by day. Protracted and patient effort is needed to develop good DBAs.
    Spoon feeding : To treat (another) in a way that discourages independent thought or action, as by overindulgence.
    DB2 UDB LUW Certified V7-V8-V9-V9.7-V10.1-V10.5 DB Admin - Advanced DBA -Dprop..
    Information Server Datastage Certified
    http://www.infocura.be

  3. #3
    Join Date
    Jan 2004
    Location
    UK
    Posts
    11
    db2 "select colname from syscat.columns where PARTKEYSEQ=1 and tabname='<TABLENAME>'"

  4. #4
    Join Date
    Aug 2011
    Posts
    10

    @prakash

    Thanks prakash , I got what I expected.

  5. #5
    Join Date
    Aug 2011
    Posts
    10
    i want the column name

  6. #6
    Join Date
    Jan 2009
    Location
    Zoetermeer, Holland
    Posts
    746
    Look at db2look

  7. #7
    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 12:51.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •