Lijo Lijo - 2 months ago 13
SQL Question

Definition of a view in DB2

Is there any query/SQL Statement to see definition of a

view
in
DB2
?

I tried the following and it is resulting in an error as shown below

SELECT * FROM SYSCAT.VIEWS


enter image description here

REFERENCE:


  1. show create view definition

  2. How to view DB2 Table structure



VERSION:

Test results based on How to check db2 version are listed below (for version)

enter image description here



Answer

If you have admin permissions to the database, you can use the db2look utility:

db2look.exe -i your_userid -w your_password -d your_database -e -t your_table

Change the variables that start with your_.

If that doesn't work for you, you should be able to do:

SELECT TEXT
FROM SYSIBM.SYSVIEWS

If your platform (I can't see your picture for some reason) is the Mainframe DB2 (z/OS), then be aware that the catalog view will only show a part of the definition, if it's very long, it'll be cut off (on mine, z/OS v9.1, it only shows the first 1500 characters of the definition).