以下是在常见数据库中查询前 100 行数据的 SQL 写法:

1. MySQL:


select * from table_name limit 0, 100;
    或者也可以写成:
select * from table_name limit 100;
    这两种写法在 MySQL 中都是可以的,都是查询table_name表中的前 100 行数据。

 

2. Oracle:


select * from table_name where rownum <= 100;
    如果想要先对数据进行排序再取前 100 行,则需要使用子查询,例如按照某个字段column_name排序后取前 100 行:
select * from (select * from table_name order by column_name) where rownum <= 100;


3. SQL Server:


select top 100 * from table_name;


4. DB2:


select * from table_name fetch first 100 rows only;


5. Progress OpenEdge:


select top 100 * from table_name;

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐