sql在不同資料庫查詢前幾條資料

2021-08-22 17:43:25 字數 852 閱讀 3679

sql在不同資料庫查詢前幾條資料

1. oracle

select * from table1 where rownum<=n

hql: from table1 t order by t.createtime desc where rownum<=n

2. informix

select first n * from table1

3. db2

select * row_number() over(order by col1 desc) as rownum where rownum<=n

或者select column from table fetch first n rows only

4. sql server

select top n * from table1

5. sybase

set rowcount n

goselect * from table1

6. mysql

select * from table1 limit n

hibernate查詢記錄的前10條記錄

就像mysql的sql語句的"select * from table limit 10" hql 不支援limit

query.setfirstresult(0);//從第0條開始取

query.setmaxresults(10);//取十條記錄

7. foxpro

select * top n from table order by column

8.postgres查詢前幾條記錄sql

select * from table limit

sql在不同資料庫查詢前幾條資料

sql在不同資料庫查詢前幾條資料 1.oracle select from table1 where rownum n hql from table1 t order by t.createtime desc where rownum n 2.informix select first n from...

各種資料庫查詢前幾條資料

1.oracle資料庫 select from tablename where rownum n 2.infomix資料庫 select first n from tablename 3.db2資料庫 select from select row number over as rownum from...

查詢前幾條記錄SQL在不同資料庫中的用法

查詢前幾條記錄sql在不同資料庫中的用法 1.oracle select from table1 whererownum n 2.informix selectfirstn from table1 3.db2 select row number over order by col1 desc as ...