Oracle ¶àÐмǼºÏ²¢/Á¬½Ó/¾ÛºÏ×Ö·û´®µÄ¼¸ÖÖ·½·¨
ʲôÊǺϲ¢¶àÐÐ×Ö·û´®£¨Á¬½Ó×Ö·û´®£©ÄØ£¬ÀýÈ磺
SQL> desc test;
Name Type Nullable Default Comments
------- ------------ -------- ------- --------
COUNTRY VARCHAR2(20) Y
CITY VARCHAR2(20) Y
SQL> select * from test;
COUNTRY CITY
-------------------- --------------------
Öйú ̨±±
Öйú Ïã¸Û
Öйú ÉϺ£
ÈÕ±¾ ¶«¾©
ÈÕ±¾ ´óÚæ
ÒªÇóµÃµ½ÈçϽá¹û¼¯£º
------- --------------------
Öйú ̨±±,Ïã¸Û,ÉϺ£
ÈÕ±¾ ¶«¾©£¬´óÚæ
ʵ¼Ê¾ÍÊǶÔ×Ö·ûʵÏÖÒ»¸ö¾ÛºÏ¹¦ÄÜ£¬ÎÒºÜÆæ¹ÖΪʲôOracleûÓÐÌṩ¹Ù·½µÄ¾ÛºÏº¯ÊýÀ´ÊµÏÖËüÄØ£º£©
ÏÂÃæ¾Í¶Ô¼¸ÖÖ¾³£Ìá¼°µÄ½â¾ö·½°¸½øÐзÖÎö£¨ÓÐÒ»¸öÆÀ²â±ê×¼×î¸ß¡ï¡ï¡ï¡ï¡ï£©£º
1.±»¼¯ºÏ×ֶη¶Î§Ð¡Çҹ̶¨ÐÍ Áé»îÐÔ¡ï ÐÔÄÜ¡ï¡ï¡ï¡ï ÄÑ¶È ¡ï
ÕâÖÖ·½·¨µÄÔÀíÔÚÓÚÄãÒѾ֪µÀ CITY×ֶεÄÖµÓм¸ÖÖ£¬ÇÒ»¹²»ËãÌ«¶à£¬Èç¹ûÌ«¶àÕâ¸öSQL¾Í»áÏ൱µÄ³¤¡£¡£¿´Àý×Ó£º
SQL> select t.country,
2 MAX(decode(t.city,'̨±±',t.city||',',NULL)) ||
3 MAX(decode(t.city,'Ïã¸Û',t.city||',',NULL))||
4 MAX(decode(t.city,'ÉϺ£',t.city||',',NULL))||
5 MAX(decode(t.city,'¶«¾©',t.city||',',NULL))||
6 MAX(decode(t.city,'´óÚæ',t.city||',',NULL))
7 from test t GROUP BY t.country
8 /
COUNTRY MAX(DECODE(T.CITY,'̨±±',T.CIT
-------------------- ------------------------------
Öйú ̨±±,Ïã¸Û,ÉϺ£,
ÈÕ±¾ ¶«¾©,´óÚæ,
´ó¼ÒÒ»¿´£¬¹À¼Æ¾ÍÃ÷°×ÁË£¨Èç¹û²»Ã÷°×£¬ºÃºÃ²¹Ï°MAX DECODEºÍ·Ö×飩¡£ÕâÖÖ·½·¨ÎÞÀ¢Îª×µÄ·½·¨£¬µ«ÊǶÔijЩӦÓÃÀ´Ëµ£¬×îÓÐЧµÄ·½·¨Ò²Ðí¾ÍÊÇËü¡£
2. ¹Ì¶¨±í¹Ì¶¨×ֶκ¯Êý·¨ Áé»îÐÔ¡ï¡ï ÐÔÄÜ¡ï¡ï¡ï¡ï ÄÑ¶È ¡ï¡ï
´Ë·¨±ØÐëÔ¤ÏÈÖªµÀÊÇÄĸö±í£¬Ò²¾ÍÊÇ˵һ¸ö±í¾ÍµÃдһ¸öº¯Êý£¬²»¹ý·½·¨1µÄÒ»¸öÈ¡Öµ¾ÍÒª±ã½Ý¶àÁË¡£ÔÚ´ó¶àÊýÓ¦ÓÃÖУ¬Ò²²»»á´æÔÚ´óÁ¿ÕâÖֺϲ¢×Ö·û´®µÄÐèÇó¡£·Ï»°Íê±Ï£¬¿´ÏÂÃ棺
¶¨ÒåÒ»¸öº¯Êý
create or replace function str_list( str_in in varchar2 )--·ÖÀà×Ö¶Î
return varchar2
is
str_list varchar2(4000) default null;--Á¬½Óºó×Ö·û´®
str varchar2(20) default null;--Á¬½Ó·ûºÅ
begin
for x in ( select TEST.CITY from TEST where TEST.COUNTRY = str_in ) loop
str_list := str_list || str || to_char(x.city);
str := ', ';
end loop;
return str_list;
end;
ʹÓãº
SQL> select DISTINCT(T.country),list_func1(t.country) from t
Ïà¹ØÎĵµ£º
CREATE OR REPLACE PROCEDURE kevin_proc(x varchar) IS
a VARCHAR(20);
b VARCHAR(20);
CURSOR mycur(rn NUMBER) IS SELECT * from t_kevin_test WHERE ROWNUM<rn;
BEGIN
OPEN mycur(10);
LOOP FETCH mycur INTO a,b;
EXIT WHEN mycur%NOTFOUND;
Dbms_Output.put_line('a: '||a);
Dbms_Output.put_line('b: '| ......
£¨ºìÉ«²¿·ÖΪÐÞ¸ÄÄÚÈÝ£©
µÚÒ»²½£¬ÔÚ´ÅÅÌϽ¨Ò»¸öÎļþ¼Ð£¬×¢Òâ²»ÒªÓпոñ£¬·ñÔòoracle°²×°Ê±»á³öÏÖ¾¯¸æ¡£
µÚ¶þ²½£¬ÓÃÓÚ½øÈë°²×°½çÃæºó£¬¼ì²â»·¾³ÔÚ°²×°Îļþ¼ÐÀïËÑË÷ "refhost.xml"£¬¹²2¸öÎļþ¡£
ÓüÇʱ¾´ò¿ª£¬¿´µ½
<!--Microsoft Windows vista-->
<OPERATING_SYSTEM>
&l ......
OracleÊý¾Ýµ¼Èëµ¼³öimp/exp¾ÍÏ൱ÓÚoracleÊý¾Ý»¹ÔÓ뱸·Ý¡£expÃüÁî¿ÉÒÔ°ÑÊý¾Ý´ÓÔ¶³ÌÊý¾Ý¿â·þÎñÆ÷µ¼³öµ½±¾µØµÄdmpÎļþ£¬impÃüÁî¿ÉÒÔ°ÑdmpÎļþ´Ó±¾µØµ¼Èëµ½Ô¶´¦µÄÊý¾Ý¿â·þÎñÆ÷ÖС£ÀûÓÃÕâ¸ö¹¦ÄÜ¿ÉÒÔ¹¹½¨Á½¸öÏàͬµÄÊý¾Ý¿â£¬Ò»¸öÓÃÀ´²âÊÔ£¬Ò»¸öÓÃÀ´ÕýʽʹÓá£
Ö´Ðл·¾³£º¿ÉÒÔÔÚSQLPLUS.EXE»òÕßDOS£¨ÃüÁîÐУ ......
OracleµÄÈÕÆÚº¯Êý
³£ÓÃÈÕÆÚÐͺ¯Êý
1¡£Sysdate µ±Ç°ÈÕÆÚºÍʱ¼ä
SQL> Select sysdate from dual;
SYSDATE
----------
21-6ÔÂ -05
2¡£Last_day ±¾ÔÂ×îºóÒ»Ìì
SQL> Select last_day(sysdate) from dual;
LAST_DAY(S ......
ORACLEʵÀýÓÐϵͳȫ¾ÖÇø£¨SGA£©ºÍһЩºǫ́½ø³Ì×é³É.
ϵͳȫ¾ÖÇø£¨SGA£©Óй²Ïí³Ø£¨shared pool£©,Êý¾Ý¿â¸ßËÙ»º³åÇø£¨database buffer cache£©,ÖØ×öÈÕÖ¾»º³åÇø£¨redo log buffer£©.¹²Ïí³ØÓÖÓпâ¸ßËÙ»º´æ£¨library cache£©ºÍÊý¾Ý×Öµä¸ßËÙ»º´æ£¨dictionary cache£©×é³É¡£
ORACLE ʵÀý5¸ö±ØÐèµÄºǫ́½ø³Ì£ºSMON,PMON,DBWR,LGWR, ......