oracle¶ÔtopµÄÖ§³Ö
1.ÔÚORACLEÖÐʵÏÖSELECT TOP N
ÓÉÓÚORACLE²»Ö§³ÖSELECT TOPÓï¾ä£¬ËùÒÔÔÚORACLEÖо³£ÊÇÓÃORDER BY¸úROWNUMµÄ×éºÏÀ´ÊµÏÖSELECT TOP NµÄ²éѯ¡£
¼òµ¥µØ˵£¬ÊµÏÖ·½·¨ÈçÏÂËùʾ£º
SELECT¡¡ÁÐÃû£±£®£®£®ÁÐÃû£î¡¡from
(SELECT¡¡ÁÐÃû£±£®£®£®ÁÐÃû£î¡¡from ±íÃû ORDER BY ÁÐÃû£±£®£®£®ÁÐÃû£î)
WHERE ROWNUM <= N£¨³é³ö¼Ç¼Êý£©
ORDER BY ROWNUM ASC
ÏÂÃæ¾Ù¸öÀý×Ó¼òµ¥ËµÃ÷һϡ£
¹Ë¿Í±ícustomer(id,name)ÓÐÈçÏÂÊý¾Ý£º
ID NAME
01 first
02 Second
03 third
04 forth
05 fifth
06 sixth
07 seventh
08 eighth
09 ninth
10 tenth
11 last
Ôò°´NAMEµÄ×Öĸ˳³é³öÇ°Èý¸ö¹Ë¿ÍµÄSQLÓï¾äÈçÏÂËùʾ£º
SELECT * from
(SELECT * from CUSTOMER ORDER BY NAME)
WHERE ROWNUM <= 3
ORDER BY ROWNUM ASC
Êä³ö½á¹ûΪ£º
ID NAME
08 eighth
05 fifth
01 first
2.ÔÚTOP N¼Í¼Öгé³öµÚM£¨M <= N£©Ìõ¼Ç¼
Ôڵõ½ÁËTOP NµÄÊý¾ÝÖ®ºó£¬ÎªÁ˳é³öÕâNÌõ¼Ç¼ÖеĵÚMÌõ¼Ç¼£¬ÎÒÃÇ¿ÉÒÔ¿¼ÂÇ´ÓROWNUM×ÅÊÖ¡£ÎÒÃÇÖªµÀ£¬ROWNUMÊǼǼ±íÖÐÊý¾Ý±àºÅµÄÒ»¸öÒþ²Ø×ӶΣ¬ËùÒÔ¿ÉÒÔÔڵõ½TOP NÌõ¼Ç¼µÄʱºòͬʱ³é³ö¼Ç¼µÄROWNUM£¬È»ºóÔÙ´ÓÕâNÌõ¼Ç¼ÖгéÈ¡¼Ç¼±àºÅΪMµÄ¼Ç¼£¬¼´Ê¹ÎÒÃÇÏ£ÍûµÃµ½µÄ½á¹û¡£
´ÓÉÏÃæµÄ·ÖÎö¿ÉÒÔºÜÈÝÒ׵õ½ÏÂÃæµÄSQ
Ïà¹ØÎĵµ£º
SQL*LOADERÊÇORACLEµÄÊý¾Ý¼ÓÔع¤¾ß£¬Í¨³£ÓÃÀ´½«²Ù×÷ϵͳÎļþǨÒƵ½ORACLEÊý¾Ý¿âÖС£SQL*LOADERÊÇ´óÐÍÊý¾Ý
²Ö¿âÑ¡ÔñʹÓõļÓÔØ·½·¨¡£
¡¡¡¡ÔÚNTÏ£¬SQL*LOADERµÄÃüÁîΪSQLLDR£¬ÔÚUNIXÏÂÒ»°ãΪsqlldr/sqlload¡£
¡¡¡¡ÈçÖ´ÐУºd:\oracle>sqlldr
SQL*Loader: Release 8.1.6.0.0 - Production on ÐÇÆÚ¶þ 1ÔÂ 8 11:06:42 2 ......
а²×°ÁËһ̨Êý¾Ý¿â·þÎñÆ÷£¬°æ±¾ÊÇ10.2.0.1µÄ£¬ÒòΪÏÖÔÚ×îеÄÊÇ10.2.0.4µÄ¡£ °æ±¾µÍÁË£¬bug¶à¡£ËùÒԾͶÔÊý¾Ý¿â×öÁËÒ»¸öÉý¼¶¡£
·þÎñÆ÷ÊÇwindows 2003µÄϵͳ£¬¶¼ÊÇ¿ÉÊÓ»°²Ù×÷¡£ ÏÂÒ»²½µÄÎÊÌâ¡£ 10.2.0.4µÄpatchset ÀïÃæÒ²ÓÐÏêϸµÄ°²×°ËµÃ÷¡£ Ö®×ö¸ö×ܽá ......
ÔÚijЩÌØÊâµÄÇé¿öÏ£¬ÈçÒòΪÍøÂç»òÕßXÅäÖõĹØϵÎÞ·¨Á¬½Óµ½X server»òÕßÖ÷»úÉÏûÓÐX£¬¾Í¿ÉÒÔʹÓþ²Ä¬°²×°µÄ·½Ê½°²×°Êý¾Ý¿â£¬Í¬ÑùÈç¹ûÐèÒª´ó¹æÄ£²¿Êð£¬Ôò¾²Ä¬°²×°½«»á´ó´ó¼õÇáDBAµÄÖظ´ÀͶ¯Á¦£¬¶øÇÒ¾²Ä¬°²×°²»ÐèÒªX£¬´Ó°²×°Ð§ÂÊ
ÔÚijЩÌØÊâµÄÇé¿öÏ£¬ÈçÒòΪÍøÂç»òÕßXÅäÖõĹØϵÎÞ·¨Á¬½Óµ½X server»òÕßÖ÷»úÉÏûÓÐX£ ......
1£© Ñ¡Ôñ×îÓÐЧÂʵıíÃû˳Ðò(Ö»ÔÚ»ùÓÚ¹æÔòµÄÓÅ»¯Æ÷ÖÐÓÐЧ)£º
ORACLEµÄ½âÎöÆ÷°´ÕÕ´ÓÓÒµ½×óµÄ˳Ðò´¦Àífrom×Ó¾äÖеıíÃû£¬from×Ó¾äÖÐдÔÚ×îºóµÄ±í(»ù´¡±í driving table)½«±»×îÏÈ´¦Àí£¬ÔÚfrom×Ó¾äÖаüº¬¶à¸ö±íµÄÇé¿öÏÂ,Äã±ØÐëÑ¡Ôñ¼Ç¼ÌõÊý×îÉٵıí×÷Ϊ»ù´¡±í¡£Èç¹ûÓÐ3¸öÒÔÉϵıíÁ¬½Ó²éѯ, ÄǾÍÐèҪѡÔñ½»²æ±í(intersection ......