在IBM Data Studio中记录SQL查询的方法是什么?

huangapple go评论50阅读模式
英文:

Is there a way to log SQL queries in IBM Data Studio?

问题

是否有一种方法可以从IBM Data Studio中检索发送到IBM db2数据库的SQL查询?

我需要反向工程一个与AS400应用程序关联的IBM db2数据库,但不幸的是几乎没有文档,而且许多模式/表格都相当模糊。

我已经尝试从客户端侧嗅探网络,因为我听说它通过telnet明文与服务器通信,但不幸的是SQL不是在客户端生成的。

由于我已经没有其他解决方案,我正在探索IBM Data Studio作为最后的机会。是否有人知道是否可能?

提前感谢!

英文:

Is there a way to retrieve the SQL queries sent to an IBM db 2 database from the IBM data Studio ?

I need to reverse engineer an IBM db 2 database that is tied to an AS400 application but unfortunately there is almost no documentation and a lot of schemas/tables are quite obscure.

I have tried to sniff the network from the client side as I heard it communicates in cleartext to the server (via telnet) but unfortunately the SQL is not generated client side.

As I am running out of solution I am exploring IBM Data Studio as a last chance. Does anyone know if it is possible ?

Thanks in advance !!

答案1

得分: 2

你的问题非常令人困惑...似乎表现出对IBM i平台及其前身AS/400的基本知识缺乏。

你提到Telnet,所以我认为现有的应用程序是一个绿屏5250应用程序。是的,那只是一个“愚蠢”的终端仿真。从5250客户端不使用SQL。

假设应用程序根本使用SQL,那么它将位于服务器端,嵌入在数据库或正在运行的RPG/COBOL程序中。它可能主要是本地记录级别访问(RLA)的读取和写入。

还有可能正在使用的表没有外部定义。这意味着就数据库而言,这些表由单个固定长度的字符字段组成。你需要检查RPG/COBOL程序以确定数据实际存储在记录中的方式。即使对于AS/400应用程序,我也不会指望这种情况发生,因为最初的AS/400支持外部描述的文件(表)。但如果你的应用程序是从AS/400的前身之一迁移而来...那么可能性更大。

假设表已经外部定义,SELECT * FROM MYLIB.MYTABLE将以各个列的形式返回数据。我认为IBM Data Studio不会比指向目录视图做更多的事情,这些视图都有相当详细的文档说明。

假设你实际上没有在处理AS/400,而是在运行最近版本的IBM i的现代POWER服务器上运行使用SQL的现代应用程序。那么你关于捕获SQL查询的问题的答案是,服务器内置了许多工具来管理SQL性能。包括一个自动的计划缓存,你可以使用IBM的Access Client Solutions查看最近的查询。

但要再次强调,我不会期望一个5250应用程序完全或甚至主要基于SQL。

如果你只是想反向工程数据库,如果表已经外部定义,那应该大致可行。尽管你可能会发现表/索引没有定义唯一(主要)键。

如果你试图反向工程整个应用程序,那么如果没有访问RPG/COBOL源代码,这将非常困难。

英文:

Your question is very confusing...and seems to demonstrate a lack of basic knowledge about the IBM i platform and it's predecessor the AS/400.

You mention Telnet, so I assume the existing application is a green screen 5250 application. Yeah, that's just a "dumb" terminal emulation. There's no SQL being used from the 5250 client.

Assuming the application uses SQL at all, it would be server side and embedded in the DB or the RPG/COBOL programs being run. It's probably mostly native record level access (RLA) reads and writes.

It's also possible that the tables being used are not externally defined. Meaning the as far as the DB knows, the tables are made up of a single fixed length character field. You'd have to inspect the RPG/COBOL programs to determine how the data is actually stored in the records. I wouldn't expect this even for an AS/400 application, as the original AS/400 supported externally described files (tables). But if your application was migrated from one of the AS/400's predecessors...then it's more likely.

Assuming the tables are externally defined, a SELECT * FROM MYLIB.MYTABLE will return the data in individual columns. I don't think IBM Data Studio will do much more than point you to the catalog views which are quite well documented.

Assuming you're not actually dealing with an AS/400 and instead have a somewhat modern application that uses SQL, running on a modern POWER server running a recent version of IBM i. Then the answer to your question about capturing the SQL queries being is that the server has lots of tools built in to manage SQL performance. Including an automated plan cache that you can view to see recent queries using IBM's Access Client Solutions

But to re-iterate, I wouldn't expect a 5250 application to be entirely or even mostly SQL based.

If all you're trying to do is reverse engineer the DB, that should be mostly do-able if the tables are externally defined. Though you might find out the tables / indexes don't have unique (primary) keys defined.

If you're trying to reverse engineer the entire application, that will be very difficult without access to the RPG/COBOL source.

huangapple
  • 本文由 发表于 2023年5月24日 21:21:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/76324017.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定