There is a DB2 view VIEW1. How to get the definition of this view?

DB2DatabaseBig Data Analytics

To get a DB2 view definition we can use the SYSIBM.SYSVIEW DB2 system table. The SYSVIEW table stores the details about all the views that exist in DB2. We can give below SQL statement to find the view definition.

SELECT NAME, SEQNO, TEXT
FROM SYSIBM.SYSVIEWS WHERE NAME = ‘VIEW1’
ORDER BY SEQNO;

The VIEW can have definitions in multiple lines denoted by the SEQNO. That is the reason we need to use ORDER BY SEQNO so as to give the view definition in correct order. The exact definition is available in the TEXT column.

Published on 12-Sep-2020 18:16:56