Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ORACLE rownumÓ÷¨(ZT

 
ÈçºÎÕýÈ·ÀûÓÃRownumÀ´ÏÞÖƲéѯËù·µ»ØµÄÐÐÊý£¿
º¬Òå½âÊÍ£º  
1¡¢rownumÊÇoracleϵͳ˳Ðò·ÖÅäΪ´Ó²éѯ·µ»ØµÄÐеıàºÅ£¬·µ»ØµÄµÚÒ»ÐзÖÅäµÄÊÇ1£¬µÚ¶þÐÐÊÇ2£¬
¡¡ ÒÀ´ËÀàÍÆ£¬Õâ¸öα×ֶοÉÒÔÓÃÓÚÏÞÖƲéѯ·µ»ØµÄ×ÜÐÐÊý¡£
2¡¢rownum²»ÄÜÒÔÈκλù±íµÄÃû³Æ×÷Ϊǰ׺¡£  
ʹÓ÷½·¨£º  
ÏÖÓÐÒ»¸öÉÌÆ·ÏúÊÛ±ísale£¬±í½á¹¹Îª£º
month¡¡¡¡¡¡ char(6)¡¡¡¡¡¡¡¡¡¡ --Ô·Ý
sell¡¡¡¡¡¡¡¡number(10,2)¡¡¡¡¡¡--ÔÂÏúÊÛ½ð¶î
create table sale (month char(6),sell number);
insert into sale values('200001',1000);
insert into sale values('200002',1100);
insert into sale values('200003',1200);
insert into sale values('200004',1300);
insert into sale values('200005',1400);
insert into sale values('200006',1500);
insert into sale values('200007',1600);
insert into sale values('200101',1100);
insert into sale values('200202',1200);
insert into sale values('200301',1300);
insert into sale values('200008',1000);
commit;
SQL> select rownum,month,sell from sale where rownum=1;£¨¿ÉÒÔÓÃÔÚÏÞÖÆ·µ»Ø¼Ç¼ÌõÊýµÄµØ·½£¬±£Ö¤²»³ö´í£¬È磺ÒþʽÓα꣩
   ROWNUM MONTH       SELL
--------- ------ ---------
        1 200001      1000
SQL> select rownum,month,sell from sale where rownum=2;£¨1ÒÔÉ϶¼²é²»µ½¼Ç¼£©
ûÓв鵽¼Ç¼
SQL> select rownum,month,sell from sale where rownum>5;
£¨ÓÉÓÚrownumÊÇÒ»¸ö×ÜÊÇ´Ó1¿ªÊ¼µÄαÁУ¬Oracle ÈÏΪÕâÖÖÌõ¼þ²»³ÉÁ¢£¬²é²»µ½¼Ç¼£©
ûÓв鵽¼Ç¼
Ö»·µ»ØÇ°3Ìõ¼Í¼
SQL> select rownum,month,sell from sale where rownum<4;
ROWNUM MONTH SELL
--------- ------ ---------
1 200001 1000
2 200002 1100
3 200003 1200
ÈçºÎÓÃrownumʵÏÖ´óÓÚ¡¢Ð¡ÓÚÂß¼­£¿£¨·µ»ØrownumÔÚ4—10Ö®¼äµÄÊý¾Ý£©£¨minus²Ù×÷£¬ËٶȻáÊÜÓ°Ï죩
SQL> select rownum,month,sell from sale where rownum<10
2 minus
3 select rownum,month,sell from sale where rownum<5;
ROWNUM MONTH SELL
--------- ------ ---------
5 200005 1400
6 200006 1500
7 200007 1600
8 200101 1


Ïà¹ØÎĵµ£º

Oracle ´æ´¢¹ý³Ì

 
create or replace procedure p   //ÓоÍÌæ»»£¬Ã»Óоʹ´½¨
is
     cursor c is
         select * from emp for update;
begin
  for v_emp in c loop
      if (v_emp.deptno =10) then
 &nb ......

Oracle ·ÖÎöº¯Êý


   ·ÖÎöº¯ÊýÊÇoracle816ÒýÈëµÄÒ»¸öȫеĸÅÄî,ΪÎÒÃÇ·ÖÎöÊý¾ÝÌṩÁËÒ»ÖÖ¼òµ¥¸ßЧµÄ´¦Àí·½Ê½.ÔÚ·ÖÎöº¯Êý³öÏÖÒÔÇ°,ÎÒÃDZØÐëʹÓÃ×ÔÁª²éѯ,×Ó²éѯ»òÕßÄÚÁªÊÓͼ,ÉõÖÁ¸´ÔӵĴ洢¹ý³ÌʵÏÖµÄÓï¾ä,ÏÖÔÚÖ»ÒªÒ»Ìõ¼òµ¥µÄsqlÓï¾ä¾Í¿ÉÒÔʵÏÖÁË,¶øÇÒÔÚÖ´ÐÐЧÂÊ·½ÃæÒ²ÓÐÏ൱´óµÄÌá¸ß.
ÏÂÃæÖ÷Òª½éÉÜÒ»ÏÂÒÔϼ¸¸öº¯ÊýµÄʹÓà ......

oracleÖÐʵÏֵݹé²éѯµÄSQL£¨connect by prior£©

    Ç°¶Îʱ¼ä×öÁËÒ»¸öÐéÄâ×éÖ¯µÄ´´½¨¡£Õâ¸öÐéÄâ×éÖ¯µÄ´´½¨ÊÇ´ÓÏÖÓеÄ×éÖ¯ÖжÁÈ¡Êý¾ÝÈ»ºó½øÐзÖÎö±£´æµ½ÐéÄâ×éÖ¯±íÖС£±£´æÖ®ºóдÈÕÖ¾·½±ãͬ²½µ½ÆäËüϵͳÖС£¹«Ë¾Ê¹ÓõÄÖ÷Òª¼¼ÊõÊÇSSH¡£ÓÉÓÚÊÇÐÂÈËûÓÐʲô¾­Ñ飬¼Ó֮ʱ¼ä±È½Ï½ôÆÈ£¬×îºóʹÓÃÒ»°ãµÄÂß¼­Ë¼Ïëͨ¹ýµÝ¹éÔÚhibernateÏÂ˳Àû´´½¨ÁË¡£¿ÉÊÇ´ÓÏÖÓеÄ×éÖ¯Ö ......

OracleÖеÄcovering index

 CSDNÀïµÄÒ»¸öÅóÓÑÎʵ½ÁËÕâ¸öË÷Òý¸²¸ÇµÄ¸ÅÄî¡£ Õâ¸ö¸ÅÄîºÜСµÄ֪ʶµã£¬ÔÚÎÒµÄÂÛ̳ÀïÓнâÊÍ“”£¬²»¹ý×÷ΪOracle°æÖ÷£¬²»ÄÜÔÚ»ØÌûÀï¼ÓÉÏÍøÍâµÄµØÖ·Á´½Ó£¬ËùÒÔÕâÀïÔÚCSDNÀïÌûÉÏÒ»·Ý
±ÈÈçÓи´ºÏË÷ÒýΪ3¸ö×ֶΣºf1 + f2 + f3,ÇëÎÊ: 
1: select f1, f2, f3, f4 from table where f1 = 'XX' and f2 = 'XX'. ......

oracle»ù´¡ÖªÊ¶1

 
1¡¢Ä¬ÈÏÊÂÀý£º
Óû§Ãû£ºscottÃÜÂ룺tiger Ö÷»ú×Ö·û´®£º±¾»ú¿ÉÒÔΪ¿Õ
2¡¢Æô¶¯·½·¨£º
ÔËÐУºsqlplus scott/tiger@lhd
3¡¢SQLPLUS»ù±¾ÃüÁ
Desc£ºÏÔʾ±í¡¢ÊÓͼ½á¹¹  desc ±íÃû£¬ÊÓͼ
List£ºÁгöSQL»º³åÇøÇøÖеÄÒ»Ðлò¶àÐÐÃüÁîÓï¾ä
Exit£ºÍ˳ö
4¡¢³£ÓõÄÊý¾Ý×Öµä(ÈýÖÖǰ׺£ºUSER£¬ALL£¬DBA)
USER_TABLE ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ