Personal tools
You are here: Home DB2 DB2 EEE How to find out which columns make up the partitioning key of a partitioned table
Navigation
Log in


Forgot your password?
 
Document Actions

How to find out which columns make up the partitioning key of a partitioned table

syscat.columns - PARTKEYSEQ

Perform the query below :

db2 "SELECT COLNAME, PARTKEYSEQ FROM SYSCAT.COLUMNS WHERE TABNAME = '<TableName>'  AND PARTKEYSEQ != 0 \
ORDER BY PARTKEYSEQ"

 

Example:  If you wanted to obtain information about the partitioning key that has been defined for a table named EMPLOYEES, you could do so by executing the following query: 

 

db2 "SELECT COLNAME, PARTKEYSEQ FROM SYSCAT.COLUMNS WHERE TABNAME = 'EMPLOYEES'  AND PARTKEYSEQ != 0 \
ORDER BY PARTKEYSEQ"


Assuming the table EMPLOYEES was created by executing the following CREATE TABLE SQL statement:

CREATE TABLE employees (

    empid      INTEGER NOT NULL

    name       VARCHAR(75),

    ssn        CHAR(12),

    dept       CHAR(3),

    salary     DECIMAL(8,2),

    hire_date  DATE)

  PARTITIONING KEY (empid, ssn)


the results produced by the query should look something like this: 

 

COLNAME                    PARTKEYSEQ

-------------------------- ----------

EMPID                      1

SSN                        2

  2 record(s) selected.

 

This indicates that the partitioning key for the EMPLOYEES table is comprised of the columns EMPID and SSN.

Security Awareness
Would you like your company to implement gamification into your security awareness program?





Polls