Getting top n to n rows from db2(从 db2 获取前 n 到 n 行)
问题描述
我需要将一个巨大的表格分成多个块.
I need to split a huge table in to chunks.
从 DB2 中获取数据并在 SSIS 中处理
Fetching data from DB2 and processing in SSIS
迭代1:获取前10行并处理
iteration 1 : Get first 10 rows and process it
迭代2:获取下10行(11-20)并处理
iteration 2 : Get next 10 rows(11-20) and process it
迭代3:获取接下来的10行(21-30)并处理
iteration 3 : Get next 10 rows(21-30) and process it
依此类推,直到一个表的count(*)
and so on till count(*) of a table
是否可以从 db2 中获取前 n 到 n 行
Is it possible to get top n to n rows from db2
我正在寻找如下查询,
select * from from tablename fetch 10 到 20 行
select * from from tablename fetch 10 to 20 rows
推荐答案
https://www.ibm.com/support/knowledgecenter/en/SSEPGG_11.1.0/com.ibm.db2.luw.sql.ref.doc/doc/r0061832.html
db2 "select row_number() over(order by tabschema, tabname)
, tabschema::char(10), tabname::char(30)
from syscat.tables
order by tabschema, tabname
offset 10 rows
fetch first 10 rows only"
1 2 3
-------------------- ---------- ------------------------------
11 SYSCAT COLCHECKS
12 SYSCAT COLDIST
13 SYSCAT COLGROUPCOLS
14 SYSCAT COLGROUPDIST
15 SYSCAT COLGROUPDISTCOUNTS
16 SYSCAT COLGROUPS
17 SYSCAT COLIDENTATTRIBUTES
18 SYSCAT COLLATIONS
19 SYSCAT COLOPTIONS
20 SYSCAT COLUMNS
10 record(s) selected.
这篇关于从 db2 获取前 n 到 n 行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:从 db2 获取前 n 到 n 行
基础教程推荐
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- 在 SQL 中连接多个表 2021-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- 是否可以执行按位分组功能? 2021-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- 无法解决整理冲突 2021-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
