数据库取表的前n条记录

 关于row_number() over()的用法

介绍取一表前n笔记录的各种数据库的写法...

1. oracle

Select * from table1 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

Db2

Select column from table fetch first n rows only

4. sql server

Select top n * from table1

5. sybase

Select top n * from table1

6. mysql:

Select * from table_name limit n

猜你喜欢

转载自zhoujingxian.iteye.com/blog/1635241