oracleÖзÖÒ³µÄʵÏÖ·½Ê½.rownumµÄʹÓÃ
¶ÔÓÚrownumÀ´ËµËüÊÇoracleϵͳ˳Ðò·ÖÅäΪ´Ó²éѯ·µ»ØµÄÐеıàºÅ£¬·µ»ØµÄµÚÒ»ÐзÖÅäµÄÊÇ1£¬µÚ¶þÐÐÊÇ2£¬ÒÀ´ËÀàÍÆ£¬Õâ¸öα×ֶοÉÒÔÓÃÓÚÏÞÖƲéѯ·µ»ØµÄ×ÜÐÐÊý£¬¶øÇÒrownum²»ÄÜÒÔÈκαíµÄÃû³Æ×÷Ϊǰ׺¡£
¾ÙÀý˵Ã÷£º
ÀýÈç±í£ºstudent(ѧÉú)±í£¬±í½á¹¹Îª£º
ID¡¡¡¡¡¡ char(6)¡¡¡¡¡¡¡¡¡¡ --ѧºÅ
name¡¡¡¡¡¡¡¡VARCHAR2(10)¡¡¡¡¡¡--ÐÕÃû
create table student (ID char(6), name VARCHAR2(100));
insert into sale values('200001',‘ÕÅÒ»’);
insert into sale values('200002',‘Íõ¶þ’);
insert into sale values('200003',‘ÀîÈý’);
insert into sale values('200004',‘ÕÔËÄ’);
commit;
(1) rownum ¶ÔÓÚµÈÓÚijֵµÄ²éѯÌõ¼þ
Èç¹ûÏ£ÍûÕÒµ½Ñ§Éú±íÖеÚÒ»ÌõѧÉúµÄÐÅÏ¢£¬¿ÉÒÔʹÓÃrownum=1×÷ΪÌõ¼þ¡£µ«ÊÇÏëÕÒµ½Ñ§Éú±íÖеڶþÌõѧÉúµÄÐÅÏ¢£¬Ê¹ÓÃrownum=2½á¹û²é²»µ½Êý¾Ý¡£ÒòΪrownum¶¼ÊÇ´Ó1¿ªÊ¼£¬µ«ÊÇ1ÒÔÉϵÄ×ÔÈ»ÊýÔÚrownum×öµÈÓÚÅжÏÊÇʱÈÏΪ¶¼ÊÇfalseÌõ¼þ£¬ËùÒÔÎÞ·¨²éµ½rownum = n£¨n>1µÄ×ÔÈ»Êý£©¡£
SQL> select rownum,id,name from student where rownum=1;£¨¿ÉÒÔÓÃÔÚÏÞÖÆ·µ»Ø¼Ç¼ÌõÊýµÄµØ·½£¬±£Ö¤²»³ö´í£¬È磺ÒþʽÓα꣩
SQL> select rownum,id,name from student where rownum=1;
ROWNUM ID NAME
---------- ------ ---------------------------------------------------
1 200001 ÕÅÒ»
SQL> select rownum,id,name from student where rownum =2;
ROWNUM ID NAME
---------- ------ ---------------------------------------------------
£¨2£©rownum¶ÔÓÚ´óÓÚijֵµÄ²éѯÌõ¼þ
Èç¹ûÏëÕÒµ½´ÓµÚ¶þÐмǼÒÔºóµÄ¼Ç¼£¬µ±Ê¹ÓÃrownum>2ÊDz鲻³ö¼Ç¼µÄ£¬ÔÒòÊÇÓÉÓÚrownumÊÇÒ»¸ö×ÜÊÇ´Ó1¿ªÊ¼µÄαÁУ¬Oracle ÈÏΪrownum> n(n>1µÄ×ÔÈ»Êý)ÕâÖÖÌõ¼þÒÀ¾É²»³ÉÁ¢£¬ËùÒԲ鲻µ½¼Ç¼
SQL> select rownum,id,name from student where rownum >2;
ROWNUM ID NAME
---------- ------ ---------------------------------------------------
ÄÇÈçºÎ²ÅÄÜÕÒµ½µÚ¶þÐÐÒÔºóµÄ¼Ç¼ѽ¡£¿ÉÒÔʹÓÃÒÔϵÄ×Ó²éѯ·½·¨À´½â¾ö¡£×¢Òâ×Ó²éѯÖеÄrownum±ØÐëÒªÓбðÃû£¬·ñÔò»¹ÊDz»»á²é³ö¼Ç¼À´£¬
Ïà¹ØÎĵµ£º
OracleÊý¾Ý¿âµ¼Èëµ¼³ö£¨1£©
Oracleµ¼Èëµ¼³ö¹Ù·½¶¨Òå
ÈçºÎ²é¿´ImpºÍExpÃüÁ
Ç°Ì᣺°²×°OracleÊý¾Ý¿â»òÕß¿Í»§¶Ë¡£
Ò»¡¢ IMPÃüÁî
1. ´ò¿ªÃüÁîÌáʾ·û¡£ÀýÈ磬£¨Windows XP£© ......
£££££¹ØÓÚ·Ö×éºó×Ö¶ÎÆ´½ÓµÄÎÊÌâ
À´×Ô:www.itpub.net
×î½üÔÚÂÛ̳ÉÏ£¬¾³£»á¿´µ½¹ØÓÚ·Ö×éºó×Ö¶ÎÆ´½ÓµÄÎÊÌ⣬
´ó¸ÅÊÇÀàËÆÏÂÁеÄÇéÐΣº
SQL> select no,q from test
2 /
NO Q
---------- ------------------------------
001 n1
001 n2
001 n3
001 n4
001 n5
002 m1
003 t1
003 t2
003 t3
003 ......
oracleÊý¾Ý¿âµÄ±¸·ÝÓë»Ö¸´
---- µ±ÎÒÃÇʹÓÃÒ»¸öÊý¾Ý¿âʱ£¬×ÜÏ£ÍûÊý¾Ý¿âµÄÄÚÈÝÊÇ¿É¿¿µÄ¡¢ÕýÈ·µÄ£¬µ«ÓÉÓÚ¼ÆËã»úϵͳµÄ¹ÊÕÏ£¨°üÀ¨»úÆ÷¹ÊÕÏ¡¢½éÖʹÊÕÏ¡¢Îó²Ù×÷µÈ£©£¬Êý¾Ý¿âÓÐʱҲ¿ÉÄÜÔâµ½ÆÆ»µ£¬ÕâʱÈçºÎ¾¡¿ì»Ö¸´Êý¾Ý¾Í³ÉΪµ±ÎñÖ®¼±¡£Èç¹ûƽʱ¶ÔÊý¾Ý¿â×öÁ˱¸·Ý£¬ÄÇô´Ëʱ»Ö¸´Êý¾Ý¾ÍÏԵúÜÈÝÒס£Óɴ˿ɼû£¬×öºÃÊý¾Ý¿âµÄ±¸·ÝÊǶ ......
¸Õ¸Õ½Ó´¥ORACLEµÄÈËÀ´Ëµ,´ÓÄÇÀïѧ,ÈçºÎѧ,ÓÐÄÇЩ¹¤¾ß¿ÉÒÔʹÓÃ,Ó¦¸ÃÖ´ÐÐʲô²Ù×÷,Ò»¶¨»Ø¸Ðµ½ÎÞÖú¡£ËùÒÔÔÚѧϰʹÓÃORACLE֮ǰ£¬Ê×ÏÈÀ´°²×°Ò»ÏÂORACLE 10g£¬ÔÚÀ´ÕÆÎÕÆä»ù±¾¹¤¾ß¡£Ë×»°ËµµÄºÃ£º¹¤ÓûÉÆÆäÊ£¬±ØÏÈÀûÆäÆ÷¡£ÎÒÃÇ¿ªÊ¼°É£¡
Ê×ÏȽ«ORACLE 10gµÄ°²×°¹âÅÌ ......
¶ÔÓÚORACLEÊý¾Ý¿âµÄÊý¾Ý´æÈ¡£¬Ö÷ÒªÓÐËĸö²»Í¬µÄµ÷Õû¼¶±ð£¬µÚÒ»¼¶µ÷ÕûÊDzÙ×÷ϵͳ¼¶°üÀ¨Ó²¼þƽ̨,µÚ¶þ¼¶µ÷ÕûÊÇORACLE RDBMS¼¶µÄµ÷Õû,µÚÈý¼¶ÊÇÊý¾Ý¿âÉè¼Æ¼¶µÄµ÷Õû,×îºóÒ»¸öµ÷Õû¼¶ÊÇSQL¼¶¡£Í¨³£ÒÀ´ËËļ¶µ÷Õû¼¶±ð¶ÔÊý¾Ý¿â½øÐе÷Õû¡¢ÓÅ»¯£¬Êý¾Ý¿âµÄÕûÌåÐÔÄÜ»áµÃµ½ºÜ´óµÄ¸ÄÉÆ¡£ÏÂÃæ´Ó¼¸¸ö²»Í¬·½Ã ......