Oracle?е?SQL?????????????????
?????anxpp????? ???????[ 2016/5/30 15:15:05 ] ????????????? Oracle
?????????????????Oracle?е?????????????
????Oracle?е????????????????????????Σ??????????????Σ?????????2???????????ROWID???б????????ROWNUM???к??????????????DESCRIBE??????????????????????????е?????????????????????????????????????????????????????α?У?pseudo column????
??????????????????????Щ???????????????????
?????????
????create table users(id integer primary key??name nvarchar2(20))
?????????????
????insert into users(id??name) values(1??'tom');insert into users(id??name) values(2??'cat');insert into users(id??name) values(3??'bob');insert into users(id??name) values(4??'anxpp');insert into users(id??name) values(5??'ez');insert into users(id??name) values(6??'lily');
???????describe??????????
?????????????????н????????????Ρ?
?????????????????????????α?е????
????select rowid??rownum??id??name from users;
?????????
???????rowid????????ò?????Oracle????????????????洢?е?????λ????????18λ???????????base-64????
?????????rownum?????????????????????з???????????????????????е??к??
?????????????????????????????????????е?????п??????????????????????????檔
???????????????????????????????????2??????????2???????????1?????????????е??к??(???-1)*??????+1=3??????е??к?????*??????=4????
????select * from users where rownum>=3 rownum <= 4;
??????????????????????κν???????????Oracle??????????????????????????к??1????????>=3???????????????б????????????б???μ????У???????к????д??????????????????????????????????????У????????????????????????????鯔??????
?????????????????????????????????????????к????????????????????????????????????У?????к?????????趨?????????????????????????????д?????????????
????select id??name from( select rownum rn??u.* from users u) ua where ua.rn between 3 and 4;
???????????仹?????????>=???????????<=??????????????????????н??????????????????????????????????????SQL???£?
????select id??name from( select rownum rn??u.* from users u where rownum<=4) ua where ua.rn >= 3;
?????????
??????????????????????????????????????????????ε?????????????????? order by ????????????????????? order by ?????????rownum?????????
????select rownum??id??name from users order by name;
?????????
???????????????????к???????????????????????????к????????? order by ?????????????к??
????????????????????????飬?????????ú??????£??????????????????????????????????????????????????sql???£?
????select id??name from( (select rownum rn??uo.* from (select * from users u order by name) uo where rownum<=4)) uawhere ua.rn>=3;
????????????????????????????????id?2??5???????????
????OK??????????
?????????????????????????????????????????????????????????д???????SQL???????дSQL?????????????????????SQL??????????????
??????????Oracle?е?SQL???????????????????????????????????????Oracle????????.
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11