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

ORACLE ÖÐROWNUMÓ÷¨×ܽá!


¶ÔÓÚ Oracle µÄ rownum ÎÊÌ⣬ºÜ¶à×ÊÁ϶¼Ëµ²»Ö§³Ö>,>=,=,between...and£¬Ö»ÄÜÓÃÒÔÉÏ·ûºÅ(<¡¢<=¡¢!=)£¬²¢·Ç˵ÓÃ>,>=,=,between..and ʱ»áÌáʾSQLÓï·¨´íÎ󣬶øÊǾ­³£ÊDz鲻³öÒ»Ìõ¼Ç¼À´£¬»¹»á³öÏÖËƺõÊÇĪÃûÆäÃîµÄ½á¹ûÀ´£¬ÆäʵÄúÖ»ÒªÀí½âºÃÁËÕâ¸ö rownum αÁеÄÒâÒå¾Í²»Ó¦¸Ã¸Ðµ½¾ªÆ棬ͬÑùÊÇαÁУ¬rownum Óë rowid ¿ÉÓÐЩ²»Ò»Ñù£¬ÏÂÃæÒÔÀý×Ó˵Ã÷
¼ÙÉèij¸ö±í t1(c1) ÓÐ 20 Ìõ¼Ç¼
Èç¹ûÓà select rownum,c1 from t1 where rownum < 10, Ö»ÒªÊÇÓÃСÓںţ¬²é³öÀ´µÄ½á¹ûºÜÈÝÒ×µØÓëÒ»°ãÀí½âÔÚ¸ÅÄîÉÏÄÜ´ï³ÉÒ»Ö£¬Ó¦¸Ã²»»áÓÐÈκÎÒÉÎʵġ£
¿ÉÈç¹ûÓà select rownum,c1 from t1 where rownum > 10 (Èç¹ûдÏÂÕâÑùµÄ²éѯÓï¾ä£¬ÕâʱºòÔÚÄúµÄÍ·ÄÔÖÐÓ¦¸ÃÊÇÏëµÃµ½±íÖкóÃæ10Ìõ¼Ç¼)£¬Äã¾Í»á·¢ÏÖ£¬ÏÔʾ³öÀ´µÄ½á¹ûÒªÈÃÄúʧÍûÁË£¬Ò²ÐíÄú»¹»á»³ÒÉÊDz»Ë­É¾ÁËһЩ¼Ç¼£¬È»ºó²é¿´¼Ç¼Êý£¬ÈÔÈ»ÊÇ 20 Ìõ°¡£¿ÄÇÎÊÌâÊdzöÔÚÄÄÄØ£¿
ÏȺúÃÀí½â rownum µÄÒâÒå°É¡£ÒòΪROWNUMÊǶԽá¹û¼¯¼ÓµÄÒ»¸öαÁУ¬¼´ÏȲ鵽½á¹û¼¯Ö®ºóÔÙ¼ÓÉÏÈ¥µÄÒ»¸öÁÐ (Ç¿µ÷£ºÏÈÒªÓнá¹û¼¯)¡£¼òµ¥µÄ˵ rownum ÊǶԷûºÏÌõ¼þ½á¹ûµÄÐòÁкš£Ëü×ÜÊÇ´Ó1¿ªÊ¼ÅÅÆðµÄ¡£ËùÒÔÄãÑ¡³öµÄ½á¹û²»¿ÉÄÜûÓÐ1£¬¶øÓÐÆäËû´óÓÚ1µÄÖµ¡£ËùÒÔÄúû°ì·¨ÆÚÍûµÃµ½ÏÂÃæµÄ½á¹û¼¯£º
11 aaaaaaaa
12 bbbbbbb
13 ccccccc
.................
rownum >10 ûÓмǼ£¬ÒòΪµÚÒ»Ìõ²»Âú×ãÈ¥µôµÄ»°£¬µÚ¶þÌõµÄROWNUMÓÖ³ÉÁË1£¬ËùÒÔÓÀԶûÓÐÂú×ãÌõ¼þµÄ¼Ç¼¡£»òÕß¿ÉÒÔÕâÑùÀí½â£º
ROWNUMÊÇÒ»¸öÐòÁУ¬ÊÇoracleÊý¾Ý¿â´ÓÊý¾ÝÎļþ»ò»º³åÇøÖжÁÈ¡Êý¾ÝµÄ˳Ðò¡£ËüÈ¡µÃµÚÒ»Ìõ¼Ç¼ÔòrownumֵΪ1£¬µÚ¶þÌõΪ2£¬ÒÀ´ÎÀàÍÆ¡£Èç¹ûÄãÓÃ>,>=,=,between...andÕâЩÌõ¼þ£¬ÒòΪ´Ó»º³åÇø»òÊý¾ÝÎļþÖеõ½µÄµÚÒ»Ìõ¼Ç¼µÄrownumΪ1£¬Ôò±»É¾³ý£¬½Ó×ÅÈ¡ÏÂÌõ£¬¿ÉÊÇËüµÄrownum»¹ÊÇ1£¬ÓÖ±»É¾³ý£¬ÒÀ´ÎÀàÍÆ£¬±ãûÓÐÁËÊý¾Ý¡£
ÓÐÁËÒÔÉÏ´Ó²»Í¬·½Ã潨Á¢ÆðÀ´µÄ¶Ô rownum µÄ¸ÅÄÄÇÎÒÃÇ¿ÉÒÔÀ´ÈÏʶʹÓà rownum µÄ¼¸ÖÖÏÖÏñ
1. select rownum,c1 from t1 where rownum != 10 ΪºÎÊÇ·µ»ØÇ°9ÌõÊý¾ÝÄØ£¿ËüÓë select rownum,c1 from tablename where rownum < 10 ·µ»ØµÄ½á¹û¼¯ÊÇÒ»ÑùµÄÄØ£¿
ÒòΪÊÇÔÚ²éѯµ½½á¹û¼¯ºó£¬ÏÔʾÍêµÚ 9 Ìõ¼Ç¼ºó£¬Ö®ºóµÄ¼Ç¼Ҳ¶¼ÊÇ != 10,»òÕß >=10,ËùÒÔÖ»ÏÔʾǰÃæ9Ìõ¼Ç¼¡£Ò²¿ÉÒÔÕâÑùÀí½â£¬rownum Ϊ9ºóµÄ¼Ç¼µÄ rownumΪ10£¬ÒòÌõ¼þΪ !=10£¬ËùÒÔÈ¥µô£¬Æäºó¼Ç¼²¹ÉÏ£¬rownumÓÖÊÇ10£¬Ò²È¥µô£¬Èç¹ûÏÂÈ¥Ò²¾ÍÖ»»áÏÔʾǰÃæ9Ìõ¼Ç¼ÁË
2


Ïà¹ØÎĵµ£º

Oracle²é¿´Óû§Ëø±íÐÅÏ¢

select p.spid,
       a.serial#,
       c.object_name,
       b.session_id,
       b.oracle_username,
       b.os_user_name
  from v$proces ......

oracleÁÙʱ±í

ÔÚOracle8i»òÒÔÉÏ°æ±¾ÖУ¬¿ÉÒÔ´´½¨ÒÔÏÂÁ½ÖÖÁÙʱ±í£º
1¡£»á»°ÌØÓеÄÁÙʱ±í
    CREATE GLOBAL TEMPORARY <TABLE_NAME> (<column specification>)
    ON COMMIT PRESERVE ROWS£»
 
2¡£ÊÂÎñÌØÓеÄÁÙʱ±í
    CREATE GLOBAL TEMPORARY <TABLE_N ......

Oracle ²Ù×÷º¯Êý

º¯Êý£º
 1.ʹÓÃCreate Function Óï¾ä´´½¨
 2.Óï
·¨£º
     Create or replace Function  º¯ÊýÃû[²ÎÊýÁбí]
     Return  Êý¾ÝÀàÐÍ
IS|AS
            ¾Ö²¿±äÁ¿
     Be ......

RedHatAs5ÏÂOracleË«»úÈȱ¸£¨1£©

    ×î½üÒ»¸öÏîÄ¿µÄʵʩÐèÒªÓõ½
RedHatAs5.0
²Ù×÷ϵͳϵÄ
Oracle
Ë«»úÈȱ¸ÅäÖã¬Ô­ÒÔΪÓÐÉ豸³§ÉÌÒÔ¼°¹«Ë¾ÏµÍ³ÍøÂ粿µÄ¼¼ÊõÖ§³Ö£¬Ë«»úÈȱ¸¾ÍÊÇСÒâ˼£¬Ã»Ï뵽ʵʩ¹ý³ÌÖÐÅöµ½ÁËÐí¶àÆæ¹ÖµÄÎÊÌâ¡£¾­¹ý¶àÌìµÄ¹¥¹Ø£¬ÖÕÓÚÅäÖóɹ¦ÁË£¬¸Ð¾õÐÄÇéÌرðÇáËÉ¡£¾­¹ýÁ½ÖܵÄʵʩ£¬ÎÒÒÔÒ»¸ö
Linux
²ËÄñµÄÉí·Ý£¬³õ²½Á ......

oracle¹¤¾ß»·¾³


SQLPlusÊÇoracleÌṩµÄÒ»¸öÃüÁîÐÐÖ´ÐеŤ¾ß
SQLPlusÖÐÓÃÁ½ÖÖÃüÁ
    sqlplus£ºÒÔÃüÁîÐеķ½Ê½½øÈëÊý¾Ý¿âÁ¬½Ó
    sqlplusw£ºÒÔ´°¿ÚµÄÐÎʽÆô¶¯ÃüÁîÐй¤¾ß  ×¢£ºÖ÷»ú×Ö·û´®£¬ÊäÈëÊý¾Ý¿âÃû³Æ
             &n ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ