Db2

Db2

Connect with Db2, open source, and other data experts to gain value from your data, share insights, and solve problems.

 View Only
  • 1.  DB2LUW - How can I find the partition column of a range partitioned table?

    Posted Mon June 12, 2023 02:56 AM

    If store_id was used as the range partition table's column as shown below,

    is there any way to find the partition column of the sales_fact_tp table in the catalog table without using db2look?

    It seems that there is no such information in syscat.columns.

    Can you please help me with this?

    create table sales_fact_tp  (
    date_id date ,
    product_id integer ,
    store_id integer ,
    quantity integer ,
    price integer ,
    transaction_details char(100) )
    in data1 index in index1
    partition by range(store_id)
    (part part00 starting(minvalue) ending(50) in data1 index in index1,
    part part0 starting(51) ending(100) in data1 index in index1,
    part part1 starting(101) ending(150) in data1 index in index1,
    part part2 starting(151) ending(200) in data1 index in index1,
    part part3 starting(201) ending(250) in data1 index in index1)



    ------------------------------
    JH Kim
    ------------------------------


  • 2.  RE: DB2LUW - How can I find the partition column of a range partitioned table?

    Posted Mon June 12, 2023 03:17 AM

    Hello JH Kim,

    I believe this is what you are looking for:

    SELECT RTRIM(TABSCHEMA) AS TABSCHEMA, RTRIM(TABNAME) AS TABNAME, COLNAME, PARTKEYSEQ
        FROM SYSCAT.COLUMNS 
    WHERE PARTKEYSEQ <> 0 
    AND TABSCHEMA NOT LIKE 'SYS%'
    ORDER BY PARTKEYSEQ;

    Best regards,

    Joachim



    ------------------------------
    Joachim Müller
    ------------------------------



  • 3.  RE: DB2LUW - How can I find the partition column of a range partitioned table?

    Posted Mon June 12, 2023 03:27 AM

    Thank you for your response.

    However, the PARTKEYSEQ in syscat.columns represents the distribution key of the table.

    It seems that the range partition column information is not available in syscat.columns. 



    ------------------------------
    JH Kim
    ------------------------------



  • 4.  RE: DB2LUW - How can I find the partition column of a range partitioned table?
    Best Answer

    Posted Mon June 12, 2023 05:01 AM
    Edited by Jan Nelken Tue June 13, 2023 08:43 AM

    Columns TABSCHEMA,TABNAME,DATAPARTITIONKEYSEQ,DATAPARTITIONEXPRESSION from view SYSCAT.DATAPARTITIONEXPRESSION should identify the partition column(s) in partitioned table(s).



    ------------------------------
    Jan Nelken
    ------------------------------