从 db2 获取前 n 到 n 行 [英] Getting top n to n rows from db2

查看:34
本文介绍了从 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 行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆