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

Oracle µÄrownum Ô­ÀíºÍʹÓà ¼°ÓërowidµÄÇø±ð

Oracle µÄrownum Ô­ÀíºÍʹÓÃ
ÔÚOracle ÖУ¬Òª°´Ìض¨Ìõ¼þ²éѯǰNÌõ¼Ç¼£¬Óøörownum ¾Í¸ã¶¨ÁË¡£
select * from emp where rownum <= 5
¶øÇÒÊéÉÏÒ²¸æ½ë£¬²»ÄܶÔrownum ÓÃ">"£¬ÕâÒ²¾ÍÒâζ×Å£¬Èç¹ûÄãÏëÓÃ
select * from emp where rownum > 5
ÔòÊÇʧ°ÜµÄ¡£ÒªÖªµÀΪʲô»áʧ°Ü£¬ÔòÐèÒªÁ˽ârownum ±³ºóµÄ»úÖÆ£º
1 Oracle executes your query.
2 Oracle fetches the first row and calls it row number 1.
3 Have we gotten past row number meets the criteria? If no, then Oracle discards the row, If yes, then Oracle return the row.
4 Oracle fetches the next row and advances the row number (to 2, and then to 3, and then to 4, and so forth).
5 Go to step 3.
Á˽âÁËÔ­Àí£¬¾ÍÖªµÀrownum >²»»á³É¹¦£¬ÒòΪÔÚµÚÈý²½µÄʱºò²éѯ³öµÄÐÐÒѾ­±»¶ªÆú£¬µÚËIJ½²é³öÀ´µÄrownum ÈÔÈ»ÊÇ1,ÕâÑùÓÀÔ¶Ò²²»»á³É¹¦¡£
ͬÑùµÀÀí£¬rownum Èç¹ûµ¥¶ÀÓÃ=,Ò²Ö»ÓÐÔÚrownum =1ʱ²ÅÓÐÓá£
¶ÔÓÚ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
---


Ïà¹ØÎĵµ£º

Oracle±í¿Õ¼ä¹ÜÀí

extent--×îС¿Õ¼ä·ÖÅ䵥λ --tablespace management
block --×îСi/oµ¥Î»      --segment    management
create tablespace james
datafile '/export/home/oracle/oradata/james.dbf'
size 100M ¡¡¡¡¡¡¡¡¡¡¡¡--³õʼµÄÎļþ´óС¡¡
autoextend On¡¡¡¡¡¡¡¡ --×Ô¶¯Ôö³¤
next 10M¡ ......

oracleÊý¾Ý¿âʱ³£ÓõIJÙ×÷ÃüÁîÕûÀí

µÇ¼oracleÊý¾Ý¿âʱ³£ÓõIJÙ×÷ÃüÁîÕûÀí
1¡¢su – oracle ²»ÊDZØÐ裬ÊʺÏÓÚûÓÐDBAÃÜÂëʱʹÓ㬿ÉÒÔ²»ÓÃÃÜÂëÀ´½øÈësqlplus½çÃæ¡£
2¡¢sqlplus /nolog »òsqlplus system/manager »ò./sqlplus system/manager@ora9i
;
3¡¢SQL>connect / as sysdba ;£¨as sysoper£©»ò
connect internal/oracle AS SYSDBA ;(scott/ti ......

java´úÂëÁ¬½Óµ½oracleÊý¾Ý¿â

package com.deng.oracle;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class TestOracle {
public static void main(String[] args) {
try {
Class.forName("oracle.jdbc.driver.OracleDriv ......

Oracle À俽±¸ÊµÀý¹Òµ½ÐÂORACLEʱӦעÒâÎÊÌâ¡£

À俽±¸ÁËÒ»¸öÔ­ÓÐÊý¾Ý¿â£¬Òª°ÑËûÒÆÖ²µ½ÐµÄÊý¾Ý¿âÖÐʱ£¬Òª×¢Òâһϣº
1.Oradim -new -sid [ʵÀýÃû:demo] -intpwd [PWD]  -pfile= [Òª´´½¨ÊµÀýµÄÅäÖÃÎļþ£º*.ora]
2.set Oracle_SID=[ʵÀýÃû]£¨×°Íêºó¼ÇµÃÒªÔÚ×¢²á±íÀï¼ÓÉÏ:HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\KEY_OraDb10g_home1£ºORACLE_SID£¬ÖµÎªÊµÀýÃû¡££©
3.sql ......

oracle ¶¨Ê± ×÷Òµ Àý×Ó

sql > variable jobno  number ;
sql > begin
sql > DBMS_JOB.submit(:jobno, ' pro_name(); ' ,sysdate, ' sysdate+1 ' ); 
 dbms_job.submit(:job1, ' MYPROC; ' ,sysdate, ' sysdate+1/1440 ' );¡¡¡¡ -- ÿÌì1440·ÖÖÓ£¬¼´Ò»·ÖÖÓÔËÐÐtest¹ý³ÌÒ»´Î
sql > commit ;
sql > end ; ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ