首页 > 开发 > 综合 > 正文

教你在不同数据库环境下读取前N条记录数

2024-07-21 02:44:06
字体:
来源:转载
供稿:网友

在不同数据库环境下读取前N条记录数:

1. Oracle

Select * FROM TABLE1 Where ROWNUM<=N


2. Informix

Select FIRST N * FROM TABLE1 where 1=1


3. MySQL

Select * FROM TABLE1 where 1=1 LIMIT N

 

4. DB2

Select * ROW_NUMBER() OVER(ORDER BY COL1 DESC) AS ROWNUM Where ROWNUM<=N

或者

Select COLUMN FROM TABLE where 1=1 FETCH FIRST N ROWS ONLY


5.SQL Server

Select TOP N * FROM TABLE1 where 1=1

or

SET ROWCOUNT N Select * FROM TABLE1 where 1=1 SET ROWCOUNT N1


6. Sybase

SET ROWCOUNT N Select * FROM TABLE1 where 1=1 SET ROWCOUNT N1

 

7. FOXPRO

Select * TOP N FROM TABLE orDER BY COLUMN


8. access

Select TOP N * FROM TABLE1 where 1=1


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表