SQL DB2 中视图的定义

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14210107/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 13:01:02  来源:igfitidea点击:

Definition of a view in DB2

sqldb2

提问by LCJ

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

是否有任何查询/SQL 语句可以查看 a viewin 的定义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
  1. 显示创建视图定义
  2. 如何查看 DB2 表结构

VERSION:

版本

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

下面列出了基于How to check db2 version 的测试结果(针对版本)

enter image description here

在此处输入图片说明



回答by bhamby

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

如果您对数据库具有管理员权限,则可以使用该db2look实用程序:

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

Change the variables that start with your_.

更改以 开头的变量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).

如果您的平台(由于某种原因我看不到您的图片)是 Mainframe DB2 (z/OS),那么请注意目录视图将只显示定义的一部分,如果它很长,它将是切断(在我的 z/OS v9.1 上,它只显示定义的前 1500 个字符)。

回答by nesmoht

select name, cast(text as varchar(8000))
from SYSIBM.SYSVIEWS
where name='your table name'

In statement is the view-definition...

在声明中是视图定义...

回答by Gokuldas.Palapatta

      select name, cast(text as varchar(10000))
      from SYSIBM.SYSVIEWS
      where name='YourVIEW'