sql在不同数据库查询前几条数据

sql在不同数据库查询前几条数据

1.ORACLE

SELECT*FROMTABLE1WHEREROWNUM<=N

HQL:fromtable1torderbyt.createTimedescwhererownum<=n

2.INFORMIX

SELECTFIRSTN*FROMTABLE1

3.DB2

SELECT*ROW_NUMBER()OVER(ORDERBYCOL1DESC)ASROWNUMWHEREROWNUM<=N

或者

SELECTCOLUMNFROMTABLEFETCHFIRSTNROWSONLY

4.SQLSERVER

SELECTTOPN*FROMTABLE1

5.SYBASE

SETROWCOUNTN

GO

SELECT*FROMTABLE1

6.MYSQL

SELECT*FROMTABLE1LIMITN

hibernate查询记录的前10条记录

就像mysql的SQL语句的"select*fromtablelimit10"hql不支持limit

query.setFirstResult(0);//从第0条开始取

query.setMaxResults(10);//取十条记录

7.FOXPRO

SELECT*TOPNFROMTABLEORDERBYCOLUMN

8.postgres查询前几条记录SQL

SELECT*FROMTABLELIMIT

相关推荐