How to retrieve catalog information about a column

How to retrieve catalog information about a column
How to retrieve catalog information about a column, SYSCOLUMNS, QSYS2
How to retrieve catalog information about a column

QSYS2 schema contains a view called SYSCOLUMNS that contains a row for each column of a table and view in the schema.

Displaying all the column details of a table PF1

SELECT SYS_CNAME, SYS_TNAME, SYS_DNAME, "NULLS", "DEFAULT",       
"CCSID", COLNO, COLTYPE, LENGTH, "IDENTITY" FROM qsys2.syscolumns 
WHERE SYS_TNAME = 'PF1' and SYS_DNAME ='EASYCLASS1'               
SYSTEM_COLUMN_NAME  SYS_TNAME   SYS_DNAME   NULLS  DEFAULT          CCSID           COLNO   COLTYPE          LENGTH   IDENTITY
    EMPID           PF1         EASYCLASS1    N       Y               273               1   CHAR                 10     NO    
    EMPNAME         PF1         EASYCLASS1    N       Y               273               2   CHAR                 20     NO    
    MANAGERID       PF1         EASYCLASS1    N       Y               273               3   CHAR                 10     NO    

This table provides the column name along with its table name and schema name, type of the column, column numbers, length, scale, If it has NULLS or has default, ccsid and identity attributes etc.

Post a Comment

© AS400 and SQL Tricks. All rights reserved. Developed by Jago Desain