AS400上多成员文件的SQL查询

发布于 2024-07-09 06:43:34 字数 224 浏览 6 评论 0原文

在 AS400 上的 5250 会话中的交互式 SQL 上,

select * from myfile

仅当 myfile 具有多个成员时才返回来自一个成员的行。

如何获取特定成员的行?

重要提示:最后我想通过 JDBC 使用 jt400 来完成此操作,所以我真的想要一个可以在那里工作的解决方案。

谢谢。

On AS400 in interactive SQL in a 5250 session,

select * from myfile

returns rows from one member only when myfile has more than one member.

How can I get rows from a specific member?

Important: in the end I'd like to do this over JDBC with jt400 so really I want a solution that'll work there.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

何以畏孤独 2024-07-16 06:43:34

您可以使用 create alias 命令创建别名:

CREATE ALIAS myLibrary/myAlias FOR memberLibrary/memberFile(memberName)

这将允许您像使用任何其他文件一样使用别名对该成员运行 sql:

SELECT * FROM myLibrary/myAlias

只需记住,别名将在会话结束后保留​​下来,它们不是临时的。 因此,如果完成后不需要别名,请在 QTEMP 中创建别名,或者在完成后显式删除别名:

DROP ALIAS myLibrary/myAlias

HTH

You can create an alias using the create alias command:

CREATE ALIAS myLibrary/myAlias FOR memberLibrary/memberFile(memberName)

This will allow you to run sql against that member using the alias like you would any other file:

SELECT * FROM myLibrary/myAlias

Just remember that the alias will stick around after your session, they are not temporary. So if you wont need the alias when you are done, either create the alias in QTEMP or explicitly drop the alias once you are done with it:

DROP ALIAS myLibrary/myAlias

HTH

抹茶夏天i‖ 2024-07-16 06:43:34

为成员创建 SQL 别名并查询别名,请参阅 此页面作为示例。

Create an SQL alias for the member and query the alias, see this page for an example.

就是爱搞怪 2024-07-16 06:43:34

SQL 别名

OS/400 R430 及更高版本支持 SQL 别名语句。 为必须访问的每个成员创建一个别名,然后从应用程序引用该别名。 别名是一个持久对象——它只能创建一次。 创建 ALIAS 时,CREATE ALIAS 中引用的成员不必存在。 任何 SQL 工具,例如 OS/400i5/OS 交互式 SQL (STRSQL)iSeries Navigator 的运行 SQL 脚本 code>,可用于创建别名,例如:

CREATE ALIAS MYLIB.FILE1MBR1 FOR MYLIB.MYFILE(MBR1) 
CREATE ALIAS MYLIB.FILE1MBR2 FOR MYLIB.MYFILE(MBR2)

http:// /www-01.ibm.com/support/docview.wss?uid=nas1f1eaeecc0af19cc38625669100569213

SQL Alias

OS/400 R430 and later support an SQL alias statement. Create an alias for each member that must be accessed, then reference the alias from the application. The alias is a persistent object -- it must be created only once. The member referenced in the CREATE ALIAS does not have to exist when the ALIAS is created. Any SQL tool, such as OS/400 or i5/OS interactive SQL (STRSQL) or iSeries Navigator's Run SQL Scripts, can be used to create the alias, for example:

CREATE ALIAS MYLIB.FILE1MBR1 FOR MYLIB.MYFILE(MBR1) 
CREATE ALIAS MYLIB.FILE1MBR2 FOR MYLIB.MYFILE(MBR2)

http://www-01.ibm.com/support/docview.wss?uid=nas1f1eaeecc0af19cc38625669100569213

小巷里的女流氓 2024-07-16 06:43:34

这是一个旧线程,仍然是搜索结果列表中的第一个,我想增强之前的响应:

有时您只需要创建别名作为一次性数据库分析,然后您想要创建别名并将其删除在您提出查询后立即; 您还有一个包含许多表的数据库库,并且不想在每个查询中限定该库,因此您使用 SET SCHEMA; 我喜欢使用 QTEMP 库来创建别名,因为 IBM i AS400 服务器上的 QTEMP 本质上是用于临时对象的:

set schema=mylibrary;

create alias qtemp.aliasx for table1(membera);
create alias qtemp.aliasy for table2(memberb);

select  * from qtemp.aliasx;
select  * from qtemp.aliasy;

drop alias qtemp.aliasx;
drop alias qtemp.aliasy;

This is an old thread and still the first on the search results list, I would like to enhance the previous responses:

Sometimes you only need to create the alias as a one time Database analysis, then you want to create the alias and drop it off immediately after your query; you also have a Data Base library with many tables and don't want to qualify the library in every query so you use SET SCHEMA; I love to use the QTEMP library to create alias since QTEMP by nature on IBM i AS400 servers is for temporary objects:

set schema=mylibrary;

create alias qtemp.aliasx for table1(membera);
create alias qtemp.aliasy for table2(memberb);

select  * from qtemp.aliasx;
select  * from qtemp.aliasy;

drop alias qtemp.aliasx;
drop alias qtemp.aliasy;
第七度阳光i 2024-07-16 06:43:34

此查询在 IBM i 7.4 上运行,但也适用于某些早期版本。

选择
SYSTEM_TABLE_SCHEMA AS“库”,
SYSTEM_TABLE_NAME AS“文件”,
SYSTEM_TABLE_MEMBER AS“成员”,
SOURCE_TYPE AS“SrcType”,
TO_CHAR(NUMBER_ROWS,'999G999G999G999') AS "记录",
TO_CHAR(DATA_SIZE,'999G999G999G999') AS "大小",
PARTITION_TEXT AS“文本”,
CREATE_TIMESTAMP AS“创建日期”,
LAST_SOURCE_UPDATE_TIMESTAMP AS“上次更新”

QSYS2.SYSPARTITIONSTAT
在哪里
SYSTEM_TABLE_SCHEMA = 'XYZLIB' 和
SYSTEM_TABLE_NAME = 'XYZFILE'
并且 SOURCE_TYPE 不为空
订购依据
LAST_SOURCE_UPDATE_TIMESTAMP

This query runs on IBM i 7.4, but should work for some earlier releases as well.

SELECT
SYSTEM_TABLE_SCHEMA AS "Lib",
SYSTEM_TABLE_NAME AS "File",
SYSTEM_TABLE_MEMBER AS "Member",
SOURCE_TYPE AS "SrcType",
TO_CHAR(NUMBER_ROWS,'999G999G999G999') AS "Record",
TO_CHAR(DATA_SIZE,'999G999G999G999') AS "Size",
PARTITION_TEXT AS "Text",
CREATE_TIMESTAMP AS "CreatedDate",
LAST_SOURCE_UPDATE_TIMESTAMP AS "LastUpdated"
FROM
QSYS2.SYSPARTITIONSTAT
WHERE
SYSTEM_TABLE_SCHEMA = 'XYZLIB' and
SYSTEM_TABLE_NAME = 'XYZFILE'
AND SOURCE_TYPE IS NOT NULL
ORDER BY
LAST_SOURCE_UPDATE_TIMESTAMP

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文