1、创建测试表,
create table test_limit(id int ,value varchar(100))
2、插入测试数据,共6条记录;
insert into test_limit values (1,'v1')
insert into test_limit values (2,'v2')
insert into test_limit values (3,'v3')
insert into test_limit values (4,'v4')
insert into test_limit values (5,'v5')
insert into test_limit values (6,'v6')
3、查询表中全量数据,可以发现共6条数据,select * from test_limit t
4、编写语句,指定查询3条数据;
select * from test_limit limit 3
1、创建测试表,create table test_rows(id number, value varchar(200))
2、插入测试数据,
insert into test_rows
select level, 'val_'||level from dual
connect by level<1000
commit
3、查询表中记录数,总共有999条,
4、编写sql,返回最小的10条记录,
select * from (select t.*, row_number() over(order by id) rn from test_rows t ) where rn=10
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)