2 回答

TA貢獻(xiàn)1900條經(jīng)驗(yàn) 獲得超5個(gè)贊
可以用來進(jìn)行全前N條記錄,或者分頁操作。Oracle SQL如下:select * from sometable where rownum <= 100; select * from sometable where rownum > 100 and rownum <= 200; SELECT * FROM ( SELECT A.*,ROWNUM AS RN FROM (SELECT * FROM sometable order by col) A WHERE ROWNUM <= 200) T WHERE T.RN > 100Informix 有更簡單、高效的分頁功能: select first 100 * from sometable; select skip 100 first 100 * from sometable; select skip 100 first 100 * from sometable order by col;記錄編號:在ORACLE中,可以直接通過rownum 得到每條記錄的一個(gè)編號,select rownum, * from sometable ; Informix中需要通過創(chuàng)建一個(gè)存儲(chǔ)過程來實(shí)現(xiàn)類似功能。 CREATE FUNCTION rownum () returning int as rownum; define global counter int default 0; let counter = counter + 1; return counter; end function; CREATE PROCEDURE init_rownum (); define global counter int default 0; let counter = 0; end procedure; 可以按如下方式使用函數(shù)反問記錄編號。

TA貢獻(xiàn)1836條經(jīng)驗(yàn) 獲得超5個(gè)贊
用序列
Use the CREATE SEQUENCE statement to create a sequence database object from
which multiple users can generate unique integers.
添加回答
舉報(bào)