2

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


Community
  • 1
  • 1
LCJ
  • 22,196
  • 67
  • 260
  • 418

3 Answers3

3

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).

bhamby
  • 15,112
  • 1
  • 45
  • 66
  • Thanks. SysIBM Helped -- SELECT * FROM SYSIBM.SYSVIEWS WHERE NAME LIKE '%V1_NID%' AND CREATOR = 'ABASC' – LCJ Jan 09 '13 at 09:54
0
select name, cast(text as varchar(8000))
from SYSIBM.SYSVIEWS
where name='your table name'

In statement is the view-definition...

chanchal1987
  • 2,320
  • 7
  • 31
  • 64
nesmoht
  • 125
  • 8
0
      select name, cast(text as varchar(10000))
      from SYSIBM.SYSVIEWS
      where name='YourVIEW'