欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

数据库取表的前n条记录

程序员文章站 2022-03-26 19:19:40
...

 关于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