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

ORACLE ÐÐתÁÐ ÓùýµÚÒ»¸öЧ¹û²»ËãÌ«ºÃ£¡

Êý¾Ý¿â²éѯÖÐÄÑÃâ»áÓöµ½ÐÐÁÐת»»µÄÇé¿ö£¬ÕªÁÐһЩ½Ï¾«µäµÄ½â¾ö·½°¸
--####################################################################
Ò»¡¢²ÉÓÃSQL decodeºÍPL/SQLº¯ÊýʵÏÖ
--####################################################################
1¡¢¹Ì¶¨ÁÐÊýµÄÐÐÁÐת»»
Èç
student subject grade
---------------------------
student1 ÓïÎÄ 80
student1 Êýѧ 70
student1 Ó¢Óï 60
student2 ÓïÎÄ 90
student2 Êýѧ 80
student2 Ó¢Óï 100
……
ת»»Îª
ÓïÎÄ Êýѧ Ó¢Óï
student1 80 70 60
student2 90 80 100
……
Óï¾äÈçÏ£º
select student,sum(decode(subject,'ÓïÎÄ', grade,null)) "ÓïÎÄ",
sum(decode(subject,'Êýѧ', grade,null)) "Êýѧ",
sum(decode(subject,'Ó¢Óï', grade,null)) "Ó¢Óï"
from table
group by student
2¡¢²»¶¨ÁÐÐÐÁÐת»»
Èç
c1 c2
--------------
1 ÎÒ
1 ÊÇ
1 Ë­
2 Öª
2 µÀ
3 ²»
……
ת»»Îª
1 ÎÒÊÇË­
2 ÖªµÀ
3 ²»
ÕâÒ»ÀàÐ͵Äת»»±ØÐë½èÖúÓÚPL/SQLÀ´Íê³É£¬ÕâÀï¸øÒ»¸öÀý×Ó
CREATE OR REPLACE FUNCTION get_c2(tmp_c1 NUMBER)
RETURN VARCHAR2
IS
Col_c2 VARCHAR2(4000);
BEGIN
FOR cur IN (SELECT c2 from t WHERE c1=tmp_c1) LOOP
Col_c2 := Col_c2||cur.c2;
END LOOP;
Col_c2 := rtrim(Col_c2,1);
RETURN Col_c2;
END;
/
SQL> select distinct c1 ,get_c2(c1) cc2 from table;¼´¿É
ժ¼×Ô£ºhttp://www.360doc.com/showWeb/0/0/18772.aspx 
--####################################################################
¶þ¡¢Ê¹Ó÷ÖÎöº¯Êý½øÐÐÐÐÁÐת»»
--####################################################################
ÆäʵʹÓ÷ÖÎöº¯Êý½øÐд¦ÀíÊǺܺõķ½Ê½£¬·­Ò»ÏÂTomµÄÊ飬½«ÆäÖеÄÒ»¸öÀý×ÓÊÕ¼ÔÚÕâÀï. ±ÈÈç²éѯscott.emp±íµÄÓû§SALÅÅÐòÐÅÏ¢£¬¿ÉÒÔʹÓÃÈçϲéѯ£º
SQL> SELECT deptno, ename,
  2         ROW_NUMBER () OVER (PARTITION BY deptno ORDER BY sal DESC) seq
  3    from emp;
    DEPTNO ENAME             SEQ
---------- ---------- ----------
        10 KING &nb


Ïà¹ØÎĵµ£º

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 À俽±¸ÊµÀý¹Òµ½ÐÂ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 ÔÚwindowÏÂ×Ô¶¯±¸·Ý

£±¡¢È·¶¨ÄãµÄ¼ÆËã»úÉÏ×°ÓÐoracleµÄ¿Í»§¶Ë£¬Èç¹ûûÓУ¬Çë°²×°oracle¿Í»§¶Ë
£²¡¢È·¶¨ÓÐÄãµÄoracle·þÎñÀïÓÐÄãÒªÐèÒª±¸·ÝµÄÊý¾Ý¿âµÄ·þÎñÃû¡£
£³¡¢ÖÆ×÷Ò»¸öÅú´¦ÀíÎļþ£¨oracleBackup.bat£©£¬¾ßÌå·½·¨£º´ò¿ª“¼Çʱ¾”£¬±£´æΪoracleBackup.bat£¬
¡¡¡¡´Ëʱ±£´æµÄÎļþÀàÐÍÑ¡ÔñΪ“ËùÓÐÎļþ”¡£Îҵı£´æÄ¿Â ......

oracle ´´½¨¹ý³Ì

create table test1 as select 1 id,'create table test2(id number,name varchar2(200));insert into test2 values(1,''a'');' sqltext from dual
  2  union all select 2,'truncate table test2;' from dual
  3  union all select 3,'insert into test2 select rownum,dbms_random.string(''l'', ......

oracle·ÖÎöº¯Êýrow_number() over()ʹÓÃ

row_number() OVER (PARTITION BY COL1 ORDER BY COL2) ±íʾ¸ù¾ÝCOL1·Ö×飬ÔÚ·Ö×éÄÚ²¿¸ù¾Ý COL2ÅÅÐò£¬¶ø´Ëº¯Êý¼ÆËãµÄÖµ¾Í±íʾÿ×éÄÚ²¿ÅÅÐòºóµÄ˳Ðò±àºÅ£¨×éÄÚÁ¬ÐøµÄΨһµÄ).
  ÓërownumµÄÇø±ðÔÚÓÚ£ºÊ¹ÓÃrownum½øÐÐÅÅÐòµÄʱºòÊÇÏȶԽá¹û¼¯¼ÓÈëαÁÐrownumÈ»ºóÔÙ½øÐÐÅÅÐò£¬¶ø´Ëº¯ÊýÔÚ°üº¬ÅÅÐò´Ó¾äºóÊÇÏÈÅÅÐòÔÙ¼ÆËãÐкÅ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ