oracle rownumÎÊÌâ
½ñÌìͬÊÂÓöµ½ÁËÒ»¸öÎÊÌ⣬ÔÒòÊÇrownumµÄÎÊÌâ¡£
ÏÂÃæתһƪÎÄÕ£º
¶ÔÓÚOracleµÄrownumÎÊÌ⣬ºÜ¶à×ÊÁ϶¼Ëµ²»Ö§³Ö>£¬>=£¬=£¬between……and£¬Ö»ÄÜÓÃÒÔÉÏ·ûºÅ£¨<¡¢& lt;=¡¢£¡=£©£¬²¢·Ç˵ÓÃ>£¬>=£¬=£¬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£¬»òÕß >=
Ïà¹ØÎĵµ£º
¾²âÊÔ£¬ÔÚOracleÖУ¬¶ÔÓÚnullºÍ¿Õ×Ö·û´®'',webMethods JDBC Adapter ²éѯ³öÀ´¶¼»áÏÔʾnull.
¶øÔÚSQL SERVERÖУ¬»á·Ö±ðÏÖʵΪnullºÍ¿Õ×Ö·û´®¡£
º¬Òå½âÊÍ£º
ÎÊ£ºÊ²Ã´ÊÇNULL£¿
´ð£ºÔÚÎÒÃDz»ÖªµÀ¾ßÌåÓÐʲôÊý¾ÝµÄʱºò£¬Ò²¼´Î´Öª£¬¿ÉÒÔÓÃNULL£¬ÎÒÃdzÆËüΪ¿Õ£¬ORACLEÖУ¬º¬ÓпÕÖµµÄ±íÁ㤶ÈΪÁã¡£
ORACLEÔÊÐíÈκÎÒ»ÖÖÊý¾ ......
MySQL:
SELECT column from table
ORDER BY RAND()
LIMIT 1
PostgreSQL:
SELECT column from table
ORDER BY RANDOM()
LIMIT 1
Microsoft SQL Server:
SELECT TOP 1 column from table
ORDER BY NEWID()
IBM DB2
SELECT column, RAND() as IDX
from table
ORDER BY IDX FETCH FIRST 1 ROWS ONLY
Thanks Ti ......
´´½¨job
jobÊÇʲôÄØ? ¼òµ¥µÄ˵¾ÍÊǼƻ®(schedule)¼ÓÉÏÈÎÎñ˵Ã÷. ÁíÍ⻹ÓÐһЩ±ØÐëµÄ²ÎÊý.
ÕâÀïÌáµ½µÄ"ÈÎÎñ"¿ÉÒÔÊÇÊý¾Ý¿âÄÚ²¿µÄ´æ´¢¹ý³Ì,ÄäÃûµÄPL/SQL¿é,Ò²¿ÉÒÔÊDzÙ×÷ϵͳ¼¶±ðµÄ½Å±¾.
¿ÉÒÔÓÐÁ½ÖÖ·½Ê½À´¶¨Òå"¼Æ»®":
1) ʹÓÃDBMS_SCHDULER.CREATE_SCHEDULE ¶¨ÒåÒ»¸ö¼Æ»®;
2) µ÷ÓÃDBMS_SCHDULER.CREATE_JOBE¹ý³ÌÖ±½ÓÖ¸¶¨ ......
´øUNION ALLÎﻯÊÓͼµÄ¿ìËÙË¢ÐÂ
1. ¶¨ÒåµÄ²éѯµÄunion all²Ù×÷±ØÐëÔÚ×µÈ¼¶£¨²éѯÖØдºó£©
2. ÎﻯÊÓͼÈÕÖ¾Ö¸¶¨rowidºÍincluding new values
3. Èç¹û±íÉèÉæ¼°µ½Ò»¸ö´óÁ¿µÄinsert»òÕßÖ±½Ó·¾¶¼ÓÔØ£¬deletes,update£¬Ö¸¶¨sequencea
4. fromÁбí ......
¡¡C:\>sqlplus /nolog
¡¡¡¡SQL*Plus: Release 9.2.0.1.0 - Production on ÐÇÆÚÈý 1ÔÂ 19 14:46:21 2005
¡¡¡¡Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
¡¡¡¡SQL> connect chanet/chanet@oradb;
¡¡¡¡ÒÑÁ¬½Ó¡£
¡¡¡¡SQL> CREATE TABLE IMAGE_LOB (T_ID VARCHAR2 (5) NOT NULL,T_IMAGE ......