锘??xml version="1.0" encoding="utf-8" standalone="yes"?>国产成人亚洲精品91专区高清 ,亚洲精品精华液一区二区,亚洲精品无码av天堂http://www.tkk7.com/ywj-316/category/42587.htmlzh-cnThu, 21 Oct 2010 18:51:13 GMTThu, 21 Oct 2010 18:51:13 GMT60oracle娓告爣http://www.tkk7.com/ywj-316/archive/2010/07/29/327488.htmljunlyjunlyThu, 29 Jul 2010 09:13:00 GMThttp://www.tkk7.com/ywj-316/archive/2010/07/29/327488.htmlhttp://www.tkk7.com/ywj-316/comments/327488.htmlhttp://www.tkk7.com/ywj-316/archive/2010/07/29/327488.html#Feedback0http://www.tkk7.com/ywj-316/comments/commentRss/327488.htmlhttp://www.tkk7.com/ywj-316/services/trackbacks/327488.html--SQL娓告爣
--
娓告爣錛氭槸鎸囧悜涓婁笅鏂囧尯鐨勬寚閽?/span>
/*
  1 闅愬惈娓告爣
    闅愬惈娓告爣鍙堢ОSQL娓告爣錛屼笓闂ㄧ敤浜庡鐞哠ELECT INTO錛孖NSERT錛孶PDATE鍙奃ELETE璇彞錛屽綋鍦≒L/SQL涓墽琛?br />     INSERT錛孶PDATE鍙奃ELETE鏃訛紝涓哄彇寰桪ML璇彞浣滅敤鐨勭粨鏋滐紝蹇呴』瑕佷嬌鐢⊿QL娓告爣灞炴э紝SQL娓告爣鍖呮嫭sql%found,
    sql%notfound,sql%rowcount,sql%isopen鍥涗釜灞炴с?br />     錛?錛塻ql%isopen 鐢ㄦ棩鍏冪‘瀹歋QL娓告爣鏄惁宸茬粡鎵撳紑錛屽綋鎵цSELECT INTO錛孖NSERT錛孶PDATE鍙奃ELETE璇彞鏃朵細闅?br />          鍚墦寮娓告爣錛屽茍涓斿湪鎵ц瀹屾垚鍚庨殣鍚叧闂父鏍囥傛墍浠ュ浜庡紑鍙戜漢鍛樿灞炴ф案榪滀負false,涓嶉渶瑕佷嬌鐢ㄨ灞炴с?br />     錛?錛塻ql%found/sql%notfound 鐢ㄤ簬紜畾SQL璇彞鎵ц鏄惁鎴愬姛銆?br />          SQL璇彞鎵ц鏄惁鎴愬姛鏍規嵁鏄惁鏈変綔鐢ㄦ潵鍒ゆ柇錛屽綋SQL璇彞鏈変綔鐢ㄦ椂錛宻ql%found灞炴у間負TRUE(sql%notfound灞炴у間負FALSE)錛涘惁鍒欏弽涔嬨?/span>*/

         
declare
           v_name user_info.name
%type := 'junly';
         
begin
           
update user_info set money = money*1.1
           
where name=v_name;
           
if sql%found then
             dbms_output.put_line(
'璇彞鎵ц鎴愬姛');
           
else
             dbms_output.put_line(
'鐢ㄦ埛鍚嶄笉瀛樺湪');
           
end if;
         
end;
--   錛?錛塻ql%rowcount 榪斿洖SQL璇彞浣滅敤鐨勬昏琛屾暟
         declare
           v_name user_info.name
%type := 'junly';
         
begin
           
update user_info set money = money*1.1
           
where name=v_name;
           dbms_output.put_line(
'淇敼浜?/span>'||sql%rowcount||'琛?/span>');
         
end;
/*2 鏄懼紡娓告爣
       鐢ㄤ簬澶勭悊SELECT璇彞
*/


junly 2010-07-29 17:13 鍙戣〃璇勮
]]>
oracle鎺у埗璇彞http://www.tkk7.com/ywj-316/archive/2010/07/29/327487.htmljunlyjunlyThu, 29 Jul 2010 09:12:00 GMThttp://www.tkk7.com/ywj-316/archive/2010/07/29/327487.htmlhttp://www.tkk7.com/ywj-316/comments/327487.htmlhttp://www.tkk7.com/ywj-316/archive/2010/07/29/327487.html#Feedback0http://www.tkk7.com/ywj-316/comments/commentRss/327487.htmlhttp://www.tkk7.com/ywj-316/services/trackbacks/327487.html--鎺у埗璇彞
--
if
if condition then 
  statements;
elsif condition 
then
  statements;
else
  statements;
end if;
--case
case v_no
when 10 then
  statements;
when 20 then
  statements;
when 30 then
  statements;
else
  statements;
end case;
--------------
case 
when v_no>30 then
  statements;
when v_no>20 then
  statements;
when v_no>10 then
  statements;
end case;
--loop
loop
  statements;
  
  
exit when condition;
end loop;
--while
while condition loop
  statements;
  
end loop;
--for
for i in [reverse]
v_start..v_end loop
  statements;
end loop;
--i鏄驚鐜帶鍒跺彉閲忥紝涓嶉渶瑕佹樉寮忓畾涔夛紝v_start,v_end鍒嗗埆涓轟笅鐣屽煎拰涓婄晫鍊箋傚鏋滄寚瀹歳everse鍒欏驚鐜彉閲忚嚜鍔ㄥ噺涓銆?/span>
begin
  
for i in reverse 1..10 loop
    dbms_output.put_line(i);
  
end loop;
end;
--10,9,8,7,6,5,4,3,2,1
--
宓屽寰幆
declare
  result 
int;
begin
    
<<outer>>
    
for i in 1..10 loop
      
<<inner>>
      
for j in 1..10 loop
        result:
=i*j;
        
exit outer when i=9;
        dbms_output.put_line(i
||j);
      
end loop inner;
    
end loop outer;
end;

junly 2010-07-29 17:12 鍙戣〃璇勮
]]>
oracle鍑芥暟澶у叏http://www.tkk7.com/ywj-316/archive/2010/07/28/327354.htmljunlyjunlyWed, 28 Jul 2010 10:22:00 GMThttp://www.tkk7.com/ywj-316/archive/2010/07/28/327354.htmlhttp://www.tkk7.com/ywj-316/comments/327354.htmlhttp://www.tkk7.com/ywj-316/archive/2010/07/28/327354.html#Feedback0http://www.tkk7.com/ywj-316/comments/commentRss/327354.htmlhttp://www.tkk7.com/ywj-316/services/trackbacks/327354.html .tt { font-weight: bold; font-size: 16px; color: #F00; }

鏁板瓧鍑芥暟

1.1銆丄BS(n)鍑芥暟
鎻忚堪錛氳繑鍥炴暟鍊糿鐨勭粷瀵瑰箋?/p>

Examples錛歴elect abs(-15) “test” from dual;

1.2銆丄COS(n)鍑芥暟
鎻忚堪錛氳繑鍥炴暟鍊糿鐨勫弽浣欏雞鍊箋傝緭鍏ユ暟鍊艱寖鍥村湪-1~1涔嬮棿錛岃繑鍥炲間負寮у害銆?/p>

Examples錛歴elect acos(0.6) “test”,acos(-.6) “test1” from dual;

1.3銆丆OS(n)鍑芥暟
鎻忚堪: 榪斿洖鏁板糿鐨勪綑寮﹀箋傝繑鍥炲間負寮у害銆?/p>

Examples錛歴elect cos(1.6) “test”,cos(-6) “test1” from dual;

1.4銆丼IN(n)鍑芥暟
鎻忚堪: 榪斿洖鏁板糿鐨勬寮﹀箋?/p>

Examples錛歴elect sin(1.6) “test”,sin(-6) “test1” from dual;

1.5銆丄SIN(n)鍑芥暟
鎻忚堪: 榪斿洖鏁板糿鐨勫弽姝e雞鍊箋傝緭鍏ユ暟鍊艱寖鍥村湪-1~1涔嬮棿錛岃繑鍥炲間負寮у害銆?/p>

Examples錛歴elect asin(0.6) “test”,asin(-0.6) “test1” from dual;

1.6銆乀AN(n)鍑芥暟
鎻忚堪: 榪斿洖鏁板糿鐨勬鍒囧箋?/p>

Examples錛歴elect tan(6) “test”,tan(-0.6) “test1” from dual;

1.7銆丄TAN(n)鍑芥暟
鎻忚堪: 榪斿洖鏁板糿鐨勫弽姝e垏鍊箋傝緭鍏ユ暟鍊間換鎰忥紝榪斿洖鍊間負寮у害銆?/p>

Examples錛歴elect atan(6) “test”,atan(-0.6) “test1” from dual;

1.8銆丄TAN2(n,m)鍑芥暟
鎻忚堪: 榪斿洖鏁板糿/m鐨勫弽姝e垏鍊箋傝緭鍏ユ暟鍊間換鎰忥紝榪斿洖鍊間負寮у害銆?/p>

Examples錛歴elect atan2(19,3) “test”,atan2(-9,-0.9) “test1” from dual;

1.9銆丼INH(n)鍑芥暟
鎻忚堪: 榪斿洖鏁板糿鐨勫弻鏇叉寮﹀箋傝緭鍏ユ暟鍊間換鎰忋?/p>

Examples錛歴elect sinh(6) “test”,sinh(-0.6) “test1” from dual;

1.10銆乀ANH(n)鍑芥暟
鎻忚堪: 榪斿洖鏁板糿鐨勫弻鏇叉鍒囧箋傝緭鍏ユ暟鍊間換鎰忋?/p>

Examples錛歴elect tanh(6) “test”,tanh(-0.6) “test1” from dual;

1.11銆丆EIL(n)鍑芥暟
鎻忚堪: 榪斿洖澶т簬絳変簬鏁板糿鐨勬渶灝忔暣鏁般?/p>

Examples錛歴elect ceil(6) “test”,ceil(6.6) “test1” from dual;

1.12銆丆OSH(n)鍑芥暟
鎻忚堪: 榪斿洖鏁板糿鐨勫弻鏇蹭綑寮﹀箋?/p>

Examples錛歴elect cosh(6) “test”,cosh(6.6) “test1” from dual;

1.13銆丒XP(n)鍑芥暟
鎻忚堪: 榪斿洖e鐨刵嬈″啣銆?e=2.71828183…)

Examples錛歴elect exp(6) “test” from dual;

1.14銆丗LOOR(n)鍑芥暟
鎻忚堪: 榪斿洖灝忎簬絳変簬鏁板糿鐨勬渶澶ф暣鏁般?/p>

Examples錛歴elect floor(6) “test”,floor(9.3) “test1” from dual;

1.15銆丩N(n)鍑芥暟
鎻忚堪: 榪斿洖鏁板糿鐨勮嚜鐒跺鏁般?n蹇呴』澶т簬0)

Examples錛歴elect ln(6) “test” from dual;

1.16銆丩OG(m,n)鍑芥暟
鎻忚堪: 榪斿洖浠涓哄簳鐨勬暟鍊糿鐨勫鏁般?m>1,n>0)

Examples錛歴elect log(6,3) “test” from dual;

1.17銆丮OD(m,n)鍑芥暟
鎻忚堪: 榪斿洖m/n鍚庣殑浣欐暟錛岃嫢n=0錛屽垯榪斿洖m錛堟眰妯¤繍綆楋級

Examples錛歴elect mod(6,3) “test” from dual;

1.18銆丳OWER(m,n)鍑芥暟
鎻忚堪: 榪斿洖m鐨刵嬈″啣

Examples錛歴elect power(6,3) “test” from dual;

1.19銆丷OUND(n,[m])鍑芥暟
鎻忚堪: 鎵ц鍥涜垗浜斿叆榪愮畻錛宮鍙互鐪佺暐錛屽綋鐪佺暐m鏃訛紝鍥涜垗浜斿叆鍒版暣鏁頒綅錛涘綋m涓烘鏁版椂錛屽洓鑸嶄簲鍏ュ埌灝忔暟鐐瑰悗m浣嶏紱褰搈涓鴻礋鏁版椂錛屽洓鑸嶄簲鍏ュ埌灝忔暟鐐瑰墠m浣嶃?/p>

Examples錛歴elect round(6.698,2) “test” from dual;

1.20銆丼IGN(n)鍑芥暟
鎻忚堪: 媯嫻嬫暟鍊肩殑姝h礋錛屽綋n<0鍒欒繑鍥?1錛涘綋n>0鍒欒繑鍥?錛屽綋n=0榪斿洖0銆?/p>

Examples錛歴elect sign(6.698) “test”,sign(-9) “test1”,sign(0) “test2” from dual;

1.21銆丼QRT(n)鍑芥暟
鎻忚堪: 榪斿洖鏁板糿鐨勫鉤鏂規牴銆?n>=0)

Examples錛歴elect sqrt(6.698) “test” from dual;

1.22銆乀RUNC(n,[m])鍑芥暟
鎻忚堪: 鎴彇鏁板糿,m鍙互鐪佺暐錛屽綋鐪佺暐m鏃跺垯鎴彇n鐨勫皬鏁伴儴鍒嗭紱褰搈涓烘鏁版椂鍒欏皢n鎴彇鍒板皬鏁扮偣鍚巑浣嶏紱褰搈涓鴻礋鏁版椂鍒欏皢n鎴彇鍒板皬鏁扮偣鍓峬浣?/p>

Examples錛歴elect trunc(6.698,2) “test”,trunk(696.3,-2) “test1” from dual;

瀛楃鍑芥暟


璇存槑錛氬瓧絎﹀嚱鏁拌緭鍏ュ間負瀛楃綾誨瀷錛岃繑鍥炲間負瀛楃綾誨瀷鎴栨暟瀛楃被鍨嬶紝鍙互鍦╯ql璇彞涓洿鎺ヤ嬌鐢紝涔熷彲浠ュ湪pl/sql鍧椾腑浣跨敤銆?/p>

2.1銆丄SCII(n)鍑芥暟
鎻忚堪: 榪斿洖瀛楃涓茬殑ascii鐮?褰撹緭鍏ヤ負瀛楃涓叉椂榪斿洖絎竴涓瓧絎︾殑ascii鐮?

Examples錛歴elect ascii(‘A’) “test”,ascii(‘鎴戜滑’) “test1” from dual;

2.2銆丆HR(n)鍑芥暟
鎻忚堪: 榪斿洖瀵瑰簲鐨刟scii鐮佺殑瀛楃(n蹇呴』涓烘暟瀛楃被鍨?

Examples錛歴elect ascii(54992) “test” from dual;

2.3銆丆ONCAT(n,m)鍑芥暟
鎻忚堪: 榪炴帴n鍜宮錛宯鍜宮鍙互鏄瓧絎︼紝涔熷彲浠ユ槸瀛楃涓層備綔鐢ㄥ拰”||”涓鏍楓?/p>

Examples錛歴elect concat(‘涓浗’,’浜烘皯’) “test” from dual;

2.4銆両NITCAP(n)鍑芥暟
鎻忚堪: 灝嗗瓧絎︿覆n涓瘡涓崟璇嶉瀛楁瘝澶у啓錛屽叾浣欏皬鍐?鍖哄垎鍗曡瘝鐨勮鍒欐槸鎸夌┖鏍兼垨闈炲瓧姣嶅瓧絎︼紱鍙互杈撳叆涓枃瀛楃錛屼絾娌℃湁浠諱綍浣滅敤)

Examples錛歴elect initcap(‘涓?鍥?浜?姘?#8217;) “test”,initcap(‘my word’) “test1”,initcap(‘my涓浗word’) “test2” from dual;

2.5銆両NSTR(chr1,chr2,[n,[m]])鍑芥暟
鎻忚堪: 鑾峰彇瀛楃涓瞔hr2鍦ㄥ瓧絎︿覆chr1涓嚭鐜扮殑浣嶇疆銆俷鍜宮鍙?鐪佺暐鏄粯璁や負1錛沶浠h〃寮濮嬫煡鎵劇殑璧峰浣嶇疆錛屽綋n涓鴻礋鏁頒粠灝鵑儴寮濮嬫悳绱紱m浠h〃瀛椾覆鍑虹幇鐨勬鏁般?/p>

Examples錛歴elect instr('pplkoopijk','k',-1,1) “test” from dual;

澶囨敞錛氬綋n涓鴻礋鏁頒粠灝鵑儴鎼滅儲錛屼絾榪斿洖鍊間粛鐒舵槸鎸夋鍚戞帓鍒楀緱鍑虹殑浣嶇疆銆?/p>

2.6銆丩ENGTH(n)鍑芥暟
鎻忚堪: 榪斿洖瀛楃鎴栧瓧絎︿覆闀垮害銆?褰搉涓簄ull鏃訛紝榪斿洖nll錛涜繑鍥炵殑闀垮害鍖呮嫭鍚庨潰鐨勭┖鏍?

Examples錛歴elect length('ppl ') “test”,length(null) “test1” from dual;

2.7銆丩OWER(n)鍑芥暟
鎻忚堪: 灝唍杞崲涓哄皬鍐欍?/p>

Examples錛歴elect lower('KKKD') “test” from dual;

2.8銆丩PAD(chr1,n,[chr2])鍑芥暟
鎻忚堪: 鍦╟hr1宸﹁竟濉厖瀛楃chr2錛屼嬌寰楀瓧絎︽婚暱搴︿負n銆俢hr2鍙夛紝榛樿涓虹┖鏍鹼紱褰揷hr1瀛楃涓查暱搴﹀ぇ浜巒鏃訛紝鍒欎粠宸﹁竟鎴彇chr1鐨刵涓瓧絎︽樉紺恒?/p>

Examples錛歴elect lpad('kkk',5) “test”,lpad(‘kkkkk’,4) “test1”,lpad(‘kkk’,6,’lll’) “test2” from dual;

2.9銆丩TRIM(chr,[n])鍑芥暟
鎻忚堪: 鍘繪帀瀛楃涓瞔hr宸﹁竟鍖呭惈鐨刵瀛楃涓蹭腑鐨勪換浣曞瓧絎︼紝鐩村埌鍑虹幇涓涓笉鍖呭惈鍦╪涓殑瀛楃涓烘銆?/p>

Examples錛歴elect ltrim('abcde',’a’) “test”,ltrim(‘abcde’,’b’) “test1”,ltrim(‘abcdefg’,’cba’) “test2” from dual;

2.10銆丯LS_INITCAP(chr,[’nls_param’])鍑芥暟
鎻忚堪: 灝哻hr棣栧瓧姣嶅ぇ鍐欍侼ls_param鍙夛紝鎸囧畾鎺掑簭鐨勬柟寮忋傦紙鏈塖CHINESE_RADICAL_M錛堥儴棣栥佺瑪鐢伙級錛孲CHINESE_STROKE_M錛堢瑪鐢匯侀儴棣栵級錛孲CHINESE_PINYIN_M錛堟嫾闊籌級錛?/p>

Examples錛歴elect nls_initcap('ab cde') “test”,nls_initcap(‘a b c d e’,’nls_sort= SCHINESE_PINYIN_M’) “test1” from dual;

2.11銆丯LS_LOWER(chr,[‘nls_param’])鍑芥暟
鎻忚堪: 灝嗗瓧絎︿覆杞崲涓哄皬鍐欍侼ls_param鍙夛紝鎸囧畾鎺掑簭鐨勬柟寮忋傦紙鏈塖CHINESE_RADICAL_M錛堥儴棣栥佺瑪鐢伙級錛孲CHINESE_STROKE_M錛堢瑪鐢匯侀儴棣栵級錛孲CHINESE_PINYIN_M錛堟嫾闊籌級錛?/p>

Examples錛歴elect nls_lower('ABC') “test”,nls_lower(‘ABC’,’nls_sort= SCHINESE_PINYIN_M’) “test1” from dual;

2.12銆丯LSSORT(col,[’nls_param’])鍑芥暟
鎻忚堪: 鏍規嵁nls_param鎸囧畾鐨勬柟寮忓col瀛楁榪涜鎺掑簭銆?/p>

Examples錛歋ELECT part_number FROM cux_om_part_all ORDER BY nlssort(part_number,'nls_sort=SCHINESE_RADICAL_M')

2.13銆丯LS_UPPER(chr,[‘nls_param’])鍑芥暟
鎻忚堪: 灝哻hr杞崲涓哄ぇ鍐欍侼ls_param鍙夛紝鐢ㄤ簬鎸囧畾鎺掑簭瑙勫垯

Examples錛歋ELECT nls_upper('ddddd','nls_sort=xdanish') FROM dual

2.14銆丷EGEXP_REPLACE(source_string,pattern,replace_string,position,occurtence,match_parameter)鍑芥暟(10g鏂板嚱鏁?
鎻忚堪:瀛楃涓叉浛鎹㈠嚱鏁般傜浉褰撲簬澧炲己鐨剅eplace鍑芥暟銆係ource_string鎸囧畾婧愬瓧絎﹁〃杈懼紡錛沺attern鎸囧畾瑙勫垯琛ㄨ揪寮忥紱replace_string鎸囧畾鐢ㄤ簬鏇挎崲鐨勫瓧絎︿覆錛沺osition鎸囧畾璧峰鎼滅儲浣嶇疆錛沷ccurtence鎸囧畾鏇挎崲鍑虹幇鐨勭n涓瓧絎︿覆錛沵atch_parameter鎸囧畾榛樿鍖歸厤鎿嶄綔鐨勬枃鏈覆銆?/p>

鍏朵腑replace_string,position,occurtence,match_parameter鍙傛暟閮芥槸鍙夌殑銆?/p>

2.15銆丷EGEXP_SUBSTR(source_string, pattern[,position [, occurrence[, match_parameter]]])鍑芥暟(10g鏂板嚱鏁?
鎻忚堪錛氳繑鍥炲尮閰嶆ā寮忕殑瀛愬瓧絎︿覆銆傜浉褰撲簬澧炲己鐨剆ubstr鍑芥暟銆係ource_string鎸囧畾婧愬瓧絎﹁〃杈懼紡錛沺attern鎸囧畾瑙勫垯琛ㄨ揪寮忥紱position鎸囧畾璧峰鎼滅儲浣嶇疆錛沷ccurtence鎸囧畾鏇挎崲鍑虹幇鐨勭n涓瓧絎︿覆錛沵atch_parameter鎸囧畾榛樿鍖歸厤鎿嶄綔鐨勬枃鏈覆銆?/p>

鍏朵腑position,occurtence,match_parameter鍙傛暟閮芥槸鍙夌殑

Examples:select regexp_substr(‘http://www.oracle.com/products’,’http://([[:alnum:]]+\.?) {3,4} / ?’) “regexp_substr” from dual

2.16銆丷EGEXP_LIKE(source_string, pattern
[, match_parameter])鍑芥暟(10g鏂板嚱鏁?
鎻忚堪錛氳繑鍥炴弧瓚沖尮閰嶆ā寮忕殑瀛楃涓層傜浉褰撲簬澧炲己鐨刲ike鍑芥暟銆係ource_string鎸囧畾婧愬瓧絎﹁〃杈懼紡錛沺attern鎸囧畾瑙勫垯琛ㄨ揪寮忥紱match_parameter鎸囧畾榛樿鍖歸厤鎿嶄綔鐨勬枃鏈覆銆?/p>

鍏朵腑position,occurtence,match_parameter鍙傛暟閮芥槸鍙夌殑

Examples:

2.17銆丷EGEXP_INSTR(source_string, pattern
[, start_position
[, occurrence
[, return_option
[, match_parameter]]]])鍑芥暟(10g鏂板嚱鏁?

鎻忚堪: 璇ュ嚱鏁版煡鎵?pattern 錛屽茍榪斿洖璇ユā寮忕殑絎竴涓綅緗傛偍鍙互闅忔剰鎸囧畾鎮ㄦ兂瑕佸紑濮嬫悳绱㈢殑 start_position銆?occurrence 鍙傛暟榛樿涓?1錛岄櫎闈炴偍鎸囧畾鎮ㄨ鏌ユ壘鎺ヤ笅鏉ュ嚭鐜扮殑涓涓ā寮忋俽eturn_option 鐨勯粯璁ゅ間負 0錛屽畠榪斿洖璇ユā寮忕殑璧峰浣嶇疆錛涘間負 1 鍒欒繑鍥炵鍚堝尮閰嶆潯浠剁殑涓嬩竴涓瓧絎︾殑璧峰浣嶇疆

Examples:

 

闄勬敞錛氫笂闈㈢孩鑹叉爣棰樼殑鍥涗釜鍑芥暟鏄痮racle 10g鎵嶆湁鐨勫嚱鏁幫紝浣跨敤姝e垯琛ㄨ揪寮忓彲浠ュ疄鐜板緢寮哄ぇ鐨勫姛鑳姐傞壌浜庡彉鍖栧お澶氾紝鍙互鍙傝僶racle鐨勫畼鏂規枃妗o細SQL Reference(絎竷绔?
2.18銆丷EPLACE(chr,search_string,[,replacement_string])鍑芥暟
鎻忚堪:灝哻hr涓弧瓚硈earch_string鏉′歡鐨勬浛鎹負replacement_string鎸囧畾鐨勫瓧絎︿覆錛屽綋search_string涓簄ull鏃訛紝榪斿洖chr錛涘綋replacement_string涓簄ull鏃訛紝榪斿洖chr涓埅鍙栨帀search_string閮ㄥ垎鐨勫瓧絎︿覆銆?/p>

Examples: SELECT REPLACE('abcdeef','e','oo') "test",REPLACE('abcdeef','ee','oo') "test1",REPLACE('abcdeef',NULL,'oo') "test2",REPLACE('abcdeef','ee',NULL) "test3" FROM dual

2.19銆丷PAD(chr1,n,chr2)鍑芥暟
鎻忚堪錛氬湪chr1鍙寵竟濉厖chr2錛屼嬌榪斿洖瀛楃涓查暱搴︿負n..褰揷hr1闀垮害澶т簬n鏃訛紝榪斿洖宸︾n涓瓧絎︺傚弬鑰僉PAD()鍑芥暟銆?/p>

2.20銆丷TRIM(chr,[set])鍑芥暟
鎻忚堪錛氬幓鎺塩hr鍙寵竟鍖呭惈鐨剆et涓殑浠諱綍瀛楃錛岀洿鍒板嚭鐜頒竴涓笉鏄痵et涓殑瀛楃緇撴潫銆傚弬鑰僉TRIM()鍑芥暟銆?/p>

2.21銆丼OUNDEX(chr)鍑芥暟
鎻忚堪錛氳繑鍥炲瓧絎︿覆鐨勮闊寵〃紺猴紝鍙互鐢ㄦ潵姣旇緝瀛楃涓茬殑鍙戦煶鏄惁鐩稿悓銆?/p>

Examples:select soundex(‘ship’) “test”,soundex(‘sleep’) “test1” from dual;

2.22銆丼UBSTR(chr,m[,n])鍑芥暟
鎻忚堪錛氬彇chr鐨勫瓙涓層侻浠h〃寮濮嬩綅緗紝n鏄鍙栫殑闀垮害銆傚綋m涓?鏃朵粠棣栧瓧絎﹀紑濮嬶紝褰搈涓鴻礋鏃朵粠瀛楃涓插熬閮ㄥ紑濮嬫埅鍙栥?/p>

Examples:select substr(‘abcdef’,0,3) “test”,substr(‘abcdef’,1,3) “test1”,substr(‘abcdef’,-3,3) “test2”,substr(‘abcdef’,-1,3) “test3” from dual

娉ㄦ剰錛歮鍙?鎴?鏃訛紝寮濮嬩綅緗槸涓鏍風殑錛岄兘鏄粠絎竴浣嶅紑濮嬶紝m涓鴻礋鐨勬椂鍊欙紝浠嶇劧鏄寜浠庡乏鍒板彸鐨勯『搴忓彇錛屾墍浠ュ鏋渕涓?1錛宯鐨勯暱搴﹀啀澶э紝涔熷彧鑳藉彇鍒版渶鍚庝竴涓瓧絎︼紝鍥犱負chr鍙寵竟宸茬粡娌℃湁瀛楃浜嗐?/p>

2.23銆乀RANSLATE(chr,from_str,to_str)鍑芥暟
鎻忚堪錛氬彟涓縐嶆浛鎹㈠嚱鏁扮殑鐢ㄦ硶銆?/p>

Examples: SELECT translate('abcdeabc','abc','fgh') "test",translate('abcdeabc','abc','hf') "test1",translate('abcdeabc','ab','hfgh') "test2",translate('abcdeabc','abc',' ') "test3" FROM dual

娉ㄦ剰錛氬尮閰嶇殑瑙勫垯鏄痜rom_str鍜宼o_str姣忎釜瀛楃鎸夐『搴忕浉瀵瑰簲錛屽鏋渇rom_str瀛楃灝戜簬to_str涓殑瀛楃錛屽垯鍙浛鎹㈣兘瀵瑰簲鐨勫瓧絎︼紝to_str鍚庨潰涓嶈兘鍜宖rom_str瀵瑰簲鐨勫瓧絎﹀垯涓嶇錛屽鏋渇rom_str瀛楃澶氫簬to_str瀛楃錛屽垯from_str涓壘涓嶅埌瀵瑰簲瀛楃鎸夌収null鏉ュ鐞嗐?/p>

2.24銆乀RIM(chr)鍑芥暟
TRIM鍑芥暟灝嗗瓧絎︿覆鐨勫墠緙錛堟垨灝鵑殢錛夊瓧絎﹀垹闄ゃ?/p>

鍏跺叿浣撶殑璇硶鏍煎紡濡備笅錛?/p>

TRIM錛圼LEADING|TRAILING|BOTH][trimchar FROM] string錛?/p>

鍏朵腑錛?/p>

LEADING 鎸囨槑浠呬粎灝嗗瓧絎︿覆鐨勫墠緙瀛楃鍒犻櫎

TRAILING 鎸囨槑浠呬粎灝嗗瓧絎︿覆鐨勫熬闅忓瓧絎﹀垹闄?/p>

BOTH 鎸囨槑鏃㈠垹闄ゅ墠緙瀛楃錛屼篃鍒犻櫎灝鵑殢瀛楃銆傝繖涔熸槸榛樿鏂瑰紡

string 浠繪剰涓寰呭鐞嗗瓧絎︿覆

trimchar 鍙夐」銆傛寚鏄庤瘯鍥懼垹闄や粈涔堝瓧絎︼紝榛樿琚垹闄ょ殑瀛楃鏄┖鏍?/p>

涓嬮潰鏄鍑芥暟鐨勪嬌鐢ㄦ儏鍐碉細

TRIM錛?#8217; Ashley ’錛?‘Ashley’

TRIM錛圠EADING ’*’ FROM’***Ashley***’錛?‘Ashley***’

2.25銆乁PPER(chr)鍑芥暟
UPPER鍑芥暟闂磋繑鍥炲瓧絎︿覆鐨勫ぇ鍐欏艦寮忋?/p>

鍏跺叿浣撶殑璇硶鏍煎紡濡備笅錛?/p>

UPPER錛坰tring錛?/p>

鍏朵腑錛?/p>

string 浠繪剰VARCHAR2鎴朇HAR鍨嬪瓧絎︿覆

涓嬮潰鏄鍑芥暟鐨勪嬌鐢ㄦ儏鍐碉細

UPPER錛?#8217;THIS IS a Test’錛?‘THIS IS A TEST’

鏃ユ湡鍑芥暟

3.1銆乤dd_months(d,n)
璇存槑錛氱敤浜庝粠涓涓棩鏈熷煎鍔犳垨鍑忓皯涓浜涙湀浠?d浠h〃涓涓棩鏈?n涓烘鏁板垯浠h〃鍦╠鏃ユ湡 涓婂鍔爊鏈堜喚錛宯涓鴻礋鏁板垯浠h〃鍦╠鏃ユ湡涓婂噺灝憂鏈?
渚?select add_months(sysdate,12) "Next Year" from dual;
3.2銆乧urrent_date()

璇存槑:榪斿洖褰撳墠浼氳瘽鏃跺尯涓殑褰撳墠鏃ユ湡鏃墮棿
alter session set time_zone=’-11:00’(鏇存敼褰撳墠浼氳瘽鏃跺尯鍛戒護)
渚?select sessiontimezone,current_date from dual;
3.3銆乨btimezone()

璇存槑:榪斿洖鏁版嵁搴撳疄渚嬫椂鍖?
select dbtimezone from dual;
3.4銆乪xtract()

璇存槑:鏄劇ず鎸囧畾鏍煎紡鐨勬棩鏈熷箋?br /> select extract(month from sysdate) "This Month" from dual;
select extract(year from add_months(sysdate,36)) "3 Years Out" from dual;
3.5銆乴ast_day()

璇存槑:榪斿洖鍖呭惈浜嗘棩鏈熷弬鏁扮殑鏈堜喚鐨勬渶鍚庝竴澶╃殑鏃ユ湡
select last_day(sysdate) "last" from dual;
3.6銆乵onths_between(d1,d2)

璇存槑:榪斿洖d1鍜宒2涓や釜鏈堜喚涔嬮棿鐩稿樊鐨勬湀鏁幫紝鑻1<d2,榪斿洖璐熸暟錛沝1>d2錛岃繑鍥炴鏁幫紱鑻1鍜宒2閮芥槸鏈堝簳鎴栬呭ぉ鏁扮浉鍚岋紝鍒欒繑鍥炴暣鏁幫紝鍚﹀垯浠ユ瘡鏈?1澶╀負鍩哄噯鏁拌繑鍥炲皬鏁般?br /> select months_between(to_date('2007-01-31','yyyy-mm-dd'),to_date('2006-11-30','yyyy-mm-dd')) from dual;
3.7銆乶ext_day(d,varchar2)

璇存槑:榪斿洖鏃ユ湡d鎸囧畾鐨勫湪鏃ユ湡d涔嬪悗鐨勭涓涓伐浣滄棩錛?/p>

SELECT next_day(SYSDATE,'鏄熸湡鍥?) FROM dual;

Select next_day(sysdate,’monday’) from dual; 閿欒錛屼笉鑳戒嬌鐢ㄨ嫳鏂囧崟璇?/p>

榪斿洖褰撳墠鏃ユ湡鍚庣殑絎竴涓槦鏈熷洓鐨勬棩鏈熴傝嫢褰撳墠鏃ユ湡宸茬粡鏄槦鏈熷洓鎴栬繃浜嗘槦鏈熷洓錛屽垯榪斿洖涓嬪懆鐨勬槦鏈熷洓瀵瑰簲鐨勬棩鏈燂紝鍚﹀垯榪斿洖鏈懆鏄熸湡鍥涚殑鏃ユ湡銆?/p>

娉ㄦ剰錛歷archar2鎸囧畾宸ヤ綔鏃ョ殑鏃跺欏拰褰撳墠鏁版嵁搴撳疄渚嬬殑鍙傛暟璁劇疆鏈夊叧錛屽瓧絎︿覆闇瑕佺敤涓枃鍐欙紝濡傛灉涓枃涓嶈錛屽氨浣跨敤鑻辨枃鏄熸湡浠h〃銆?/p>

3.8銆乺ound(d,fmt)
璇存槑錛氳繑鍥炴棩鏈熸椂闂寸殑鍥涜垗浜斿叆緇撴灉銆傚鏋渇mt鎸囧畾騫達紝鍒欎互7鏈?鏃ヤ負鍒嗙晫錛涘鏋滄寚瀹氭湀錛屽垯浠?6鏃ヤ負鍒嗙晫錛涘叧浜庢寜澶╂潵鍥涜垗浜斿叆錛屽湪嫻嬭瘯鏃舵棤娉曠悊瑙?璧勬枡涓婅В閲婃寜澶╃殑鏃跺欐槸浠ヤ腑鍗?2錛?0涓哄垎鐣?

Select round(sysdate,’month’) from dual;

3.9銆乼runc(d,fmc)
璇存槑錛氭寜鐓ф寚瀹氱殑鏍煎紡鎴柇鏃ユ湡錛屽鏋滄寚瀹氭牸寮忎負騫達紝鍒欑粨鏋滀負鏈勾1鏈?鏃ワ紝濡傛灉鏍煎紡鎸囧畾涓烘湀錛屽垯緇撴灉涓烘湰鏈?鏃ワ紝鍏充簬鏍煎紡鎸囧畾涓哄ぉ榪樻湭鐞嗚В銆?/p>

SELECT trunc(SYSDATE,'month') FROM dual;

3.10銆乻ysdate

搴旂敤錛?
1. 鏃ユ湡鍜屽瓧絎﹁漿鎹㈠嚱鏁扮敤娉曪紙to_date,to_char錛?br />
select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') as nowTime from dual; //鏃ユ湡杞寲涓哄瓧絎︿覆
select to_char(sysdate,'yyyy') as nowYear from dual; //鑾峰彇鏃墮棿鐨勫勾
select to_char(sysdate,'mm') as nowMonth from dual; //鑾峰彇鏃墮棿鐨勬湀
select to_char(sysdate,'dd') as nowDay from dual; //鑾峰彇鏃墮棿鐨勬棩
select to_char(sysdate,'hh24') as nowHour from dual; //鑾峰彇鏃墮棿鐨勬椂
select to_char(sysdate,'mi') as nowMinute from dual; //鑾峰彇鏃墮棿鐨勫垎
select to_char(sysdate,'ss') as nowSecond from dual; //鑾峰彇鏃墮棿鐨勭


select to_date('2004-05-07 13:23:44','yyyy-mm-dd hh24:mi:ss') from dual//

2. select to_char( to_date(222,'J'),'Jsp') from dual

鏄劇ずTwo Hundred Twenty-Two

3.姹傛煇澶╂槸鏄熸湡鍑?
select to_char(to_date('2002-08-26','yyyy-mm-dd'),'day') from dual;
鏄熸湡涓
select to_char(to_date('2002-08-26','yyyy-mm-dd'),'day','NLS_DATE_LANGUAGE = American') from dual;
monday
璁劇疆鏃ユ湡璇█
ALTER SESSION SET NLS_DATE_LANGUAGE='AMERICAN';
涔熷彲浠ヨ繖鏍?
TO_DATE ('2002-08-26', 'YYYY-mm-dd', 'NLS_DATE_LANGUAGE = American')

4. 涓や釜鏃ユ湡闂寸殑澶╂暟
select floor(sysdate - to_date('20020405','yyyymmdd')) from dual;

5. 鏃墮棿涓簄ull鐨勭敤娉?
select id, active_date from table1
UNION
select 1, TO_DATE(null) from dual;

娉ㄦ剰瑕佺敤TO_DATE(null)

6.鏈堜喚宸?
a_date between to_date('20011201','yyyymmdd') and to_date('20011231','yyyymmdd')
閭d箞12鏈?1鍙蜂腑鍗?2鐐逛箣鍚庡拰12鏈?鍙風殑12鐐逛箣鍓嶆槸涓嶅寘鍚湪榪欎釜鑼冨洿涔嬪唴鐨勩?
鎵浠ワ紝褰撴椂闂撮渶瑕佺簿紜殑鏃跺欙紝瑙夊緱to_char榪樻槸蹇呰鐨?

7. 鏃ユ湡鏍煎紡鍐茬獊闂
杈撳叆鐨勬牸寮忚鐪嬩綘瀹夎鐨凮RACLE瀛楃闆嗙殑綾誨瀷, 姣斿: US7ASCII, date鏍煎紡鐨勭被鍨嬪氨鏄? '01-Jan-01'
alter system set NLS_DATE_LANGUAGE = American
alter session set NLS_DATE_LANGUAGE = American
鎴栬呭湪to_date涓啓
select to_char(to_date('2002-08-26','yyyy-mm-dd'),'day','NLS_DATE_LANGUAGE = American') from dual;
娉ㄦ剰鎴戣繖鍙槸涓句簡NLS_DATE_LANGUAGE錛屽綋鐒惰繕鏈夊緢澶氾紝
鍙煡鐪?
select * from nls_session_parameters
select * from V$NLS_PARAMETERS
8.
select count(*)
from ( select rownum-1 rnum
from all_objects
where rownum <= to_date('2002-02-28','yyyy-mm-dd') - to_date('2002-
02-01','yyyy-mm-dd')+1
)
where to_char( to_date('2002-02-01','yyyy-mm-dd')+rnum-1, 'D' )
not in ( '1', '7' )

鏌ユ壘2002-02-28鑷?002-02-01闂撮櫎鏄熸湡涓鍜屼竷鐨勫ぉ鏁?
鍦ㄥ墠鍚庡垎鍒皟鐢―BMS_UTILITY.GET_TIME, 璁╁悗灝嗙粨鏋滅浉鍑?寰楀埌鐨勬槸1/100縐? 鑰屼笉鏄縐?.

9. 鏌ユ壘鏈堜喚
select months_between(to_date('01-31-1999','MM-DD-YYYY'),to_date('12-31-1998','MM-DD-YYYY')) "MONTHS" FROM DUAL;
1
select months_between(to_date('02-01-1999','MM-DD-YYYY'),to_date('12-31-1998','MM-DD-YYYY')) "MONTHS" FROM DUAL;
1.03225806451613

10. Next_day鐨勭敤娉?
Next_day(date, day)

Monday-Sunday, for format code DAY
Mon-Sun, for format code DY
1-7, for format code D

11
select to_char(sysdate,'hh:mi:ss') TIME from all_objects
娉ㄦ剰錛氱涓鏉¤褰曠殑TIME 涓庢渶鍚庝竴琛屾槸涓鏍風殑
鍙互寤虹珛涓涓嚱鏁版潵澶勭悊榪欎釜闂
create or replace function sys_date return date is
begin
return sysdate;
end;

select to_char(sys_date,'hh:mi:ss') from all_objects;

12.鑾峰緱灝忔椂鏁?
extract()鎵懼嚭鏃ユ湡鎴栭棿闅斿肩殑瀛楁鍊?br /> SELECT EXTRACT(HOUR FROM TIMESTAMP '2001-02-16 2:38:40') from offer
SQL> select sysdate ,to_char(sysdate,'hh') from dual;

SYSDATE TO_CHAR(SYSDATE,'HH')
-------------------- ---------------------
2003-10-13 19:35:21 07

SQL> select sysdate ,to_char(sysdate,'hh24') from dual;

SYSDATE TO_CHAR(SYSDATE,'HH24')
-------------------- -----------------------
2003-10-13 19:35:21 19


13.騫存湀鏃ョ殑澶勭悊
select older_date,
newer_date,
years,
months,
abs(
trunc(
newer_date-
add_months( older_date,years*12+months )
)
) days

from ( select
trunc(months_between( newer_date, older_date )/12) YEARS,
mod(trunc(months_between( newer_date, older_date )),12 ) MONTHS,
newer_date,
older_date
from (
select hiredate older_date, add_months(hiredate,rownum)+rownum newer_date
from emp
)
)

14.澶勭悊鏈堜喚澶╂暟涓嶅畾鐨勫姙娉?
select to_char(add_months(last_day(sysdate) +1, -2), 'yyyymmdd'),last_day(sysdate) from dual

16.鎵懼嚭浠婂勾鐨勫ぉ鏁?
select add_months(trunc(sysdate,'year'), 12) - trunc(sysdate,'year') from dual

闂板勾鐨勫鐞嗘柟娉?
to_char( last_day( to_date('02' | | :year,'mmyyyy') ), 'dd' )
濡傛灉鏄?8灝變笉鏄棸騫?

17.yyyy涓巖rrr鐨勫尯鍒?
'YYYY99 TO_C
------- ----
yyyy 99 0099
rrrr 99 1999
yyyy 01 0001
rrrr 01 2001

18.涓嶅悓鏃跺尯鐨勫鐞?
select to_char( NEW_TIME( sysdate, 'GMT','EST'), 'dd/mm/yyyy hh:mi:ss') ,sysdate
from dual;

19.5縐掗挓涓涓棿闅?
Select TO_DATE(FLOOR(TO_CHAR(sysdate,'SSSSS')/300) * 300,'SSSSS') ,TO_CHAR(sysdate,'SSSSS')
from dual

2002-11-1 9:55:00 35786
SSSSS琛ㄧず5浣嶇鏁?

20.涓騫寸殑絎嚑澶?
select TO_CHAR(SYSDATE,'DDD'),sysdate from dual

310 2002-11-6 10:03:51

21.璁$畻灝忔椂,鍒?縐?姣
select
Days,
A,
TRUNC(A*24) Hours,
TRUNC(A*24*60 - 60*TRUNC(A*24)) Minutes,
TRUNC(A*24*60*60 - 60*TRUNC(A*24*60)) Seconds,
TRUNC(A*24*60*60*100 - 100*TRUNC(A*24*60*60)) mSeconds
from
(
select
trunc(sysdate) Days,
sysdate - trunc(sysdate) A
from dual
)

select * from tabname
order by decode(mode,'FIFO',1,-1)*to_char(rq,'yyyymmddhh24miss');

//
floor((date2-date1) /365) 浣滀負騫?
floor((date2-date1, 365) /30) 浣滀負鏈?
d(mod(date2-date1, 365), 30)浣滀負鏃?

23.next_day鍑芥暟 榪斿洖涓嬩釜鏄熸湡鐨勬棩鏈?day涓?-7鎴栨槦鏈熸棩-鏄熸湡鍏?1琛ㄧず鏄熸湡鏃?br /> next_day(sysdate,6)鏄粠褰撳墠寮濮嬩笅涓涓槦鏈熶簲銆傚悗闈㈢殑鏁板瓧鏄粠鏄熸湡鏃ュ紑濮嬬畻璧楓?
1 2 3 4 5 6 7
鏃?涓 浜?涓?鍥?浜?鍏?

---------------------------------------------------------------

select (sysdate-to_date('2003-12-03 12:55:45','yyyy-mm-dd hh24:mi:ss'))*24*60*60 from ddual
鏃ユ湡 榪斿洖鐨勬槸澶?鐒跺悗 杞崲涓簊s

24,round[鑸嶅叆鍒版渶鎺ヨ繎鐨勬棩鏈焆(day:鑸嶅叆鍒版渶鎺ヨ繎鐨勬槦鏈熸棩)
select sysdate S1,
round(sysdate) S2 ,
round(sysdate,'year') YEAR,
round(sysdate,'month') MONTH ,
round(sysdate,'day') DAY from dual

25,trunc[鎴柇鍒版渶鎺ヨ繎鐨勬棩鏈?鍗曚綅涓哄ぉ] ,榪斿洖鐨勬槸鏃ユ湡綾誨瀷
select sysdate S1,
trunc(sysdate) S2, //榪斿洖褰撳墠鏃ユ湡,鏃犳椂鍒嗙
trunc(sysdate,'year') YEAR, //榪斿洖褰撳墠騫寸殑1鏈?鏃?鏃犳椂鍒嗙
trunc(sysdate,'month') MONTH , //榪斿洖褰撳墠鏈堢殑1鏃?鏃犳椂鍒嗙
trunc(sysdate,'day') DAY //榪斿洖褰撳墠鏄熸湡鐨勬槦鏈熷ぉ,鏃犳椂鍒嗙
from dual

26,榪斿洖鏃ユ湡鍒楄〃涓渶鏅氭棩鏈?br /> select greatest('01-1鏈?04','04-1鏈?04','10-2鏈?04') from dual

27.璁$畻鏃墮棿宸?br /> 娉?oracle鏃墮棿宸槸浠ュぉ鏁頒負鍗曚綅,鎵浠ユ崲綆楁垚騫存湀,鏃?br />
select floor(to_number(sysdate-to_date('2007-11-02 15:55:03','yyyy-mm-dd hh24:mi:ss'))/365) as spanYears from dual //鏃墮棿宸?騫?br /> select ceil(moths_between(sysdate-to_date('2007-11-02 15:55:03','yyyy-mm-dd hh24:mi:ss'))) as spanMonths from dual //鏃墮棿宸?鏈?br /> select floor(to_number(sysdate-to_date('2007-11-02 15:55:03','yyyy-mm-dd hh24:mi:ss'))) as spanDays from dual //鏃墮棿宸?澶?br /> select floor(to_number(sysdate-to_date('2007-11-02 15:55:03','yyyy-mm-dd hh24:mi:ss'))*24) as spanHours from dual //鏃墮棿宸?鏃?br /> select floor(to_number(sysdate-to_date('2007-11-02 15:55:03','yyyy-mm-dd hh24:mi:ss'))*24*60) as spanMinutes from dual //鏃墮棿宸?鍒?br /> select floor(to_number(sysdate-to_date('2007-11-02 15:55:03','yyyy-mm-dd hh24:mi:ss'))*24*60*60) as spanSeconds from dual //鏃墮棿宸?縐?/p>

28.鏇存柊鏃墮棿
娉?oracle鏃墮棿鍔犲噺鏄互澶╂暟涓哄崟浣?璁炬敼鍙橀噺涓簄,鎵浠ユ崲綆楁垚騫存湀,鏃?br /> select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'),to_char(sysdate+n*365,'yyyy-mm-dd hh24:mi:ss') as newTime from dual //鏀瑰彉鏃墮棿-騫?br /> select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'),add_months(sysdate,n) as newTime from dual //鏀瑰彉鏃墮棿-鏈?br /> select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'),to_char(sysdate+n,'yyyy-mm-dd hh24:mi:ss') as newTime from dual //鏀瑰彉鏃墮棿-鏃?br /> select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'),to_char(sysdate+n/24,'yyyy-mm-dd hh24:mi:ss') as newTime from dual //鏀瑰彉鏃墮棿-鏃?br /> select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'),to_char(sysdate+n/24/60,'yyyy-mm-dd hh24:mi:ss') as newTime from dual //鏀瑰彉鏃墮棿-鍒?br /> select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'),to_char(sysdate+n/24/60/60,'yyyy-mm-dd hh24:mi:ss') as newTime from dual //鏀瑰彉鏃墮棿-縐?/p>

29.鏌ユ壘鏈堢殑絎竴澶?鏈鍚庝竴澶?br /> SELECT Trunc(Trunc(SYSDATE, 'MONTH') - 1, 'MONTH') First_Day_Last_Month,
Trunc(SYSDATE, 'MONTH') - 1 / 86400 Last_Day_Last_Month,
Trunc(SYSDATE, 'MONTH') First_Day_Cur_Month,
LAST_DAY(Trunc(SYSDATE, 'MONTH')) + 1 - 1 / 86400 Last_Day_Cur_Month
FROM dual;

杞崲鍑芥暟

4.1銆乤sciistr(str)
璇存槑錛氬皢浠繪剰瀛楃闆嗙殑瀛楃涓茶漿鎹負褰撳墠鏁版嵁搴撳疄渚嬪搴旂殑ascii瀛楃涓層?/p>

SELECT asciistr('涓崕姘戞棌') FROM dual;

澶囨敞錛氬拰璇ュ嚱鏁扮浉浼肩殑鏈塧scii,瀹冩槸鍙栧緱瀛楃涓茬涓涓瓧絎︾殑ascii鐮侊紝鍚庨潰鐨勫瓧絎︿笉綆★紱chr鏄皢ascii鐮佽漿鎹負瀵瑰簲鐨勫瓧絎︺?/p>

4.2銆乧ast()
璇存槑錛氬皢涓涓唴緗暟鎹被鍨嬫垨闆嗗悎綾誨瀷杞彉涓哄彟涓涓唴緗暟鎹被鍨嬫垨闆嗗悎綾誨瀷銆?/p>

SELECT CAST(SYSDATE AS VARCHAR2(100)) FROM dual;

4.3銆乧hartorowid(str)
璇存槑錛氬皢瀛楃涓茶漿鍙樹負rowid鏁版嵁綾誨瀷錛屼絾瀛楃涓插繀欏葷鍚坮owid鏍煎紡銆?/p>

4.4銆乧onvert(str,char_set,source_char_set)
璇存槑錛氬皢瀛楃涓蹭粠涓涓瓧絎﹂泦杞彉涓哄彟涓涓瓧絎﹂泦銆係tr涓鴻杞彉鐨勫瓧絎︿覆錛宑har_set涓鴻漿鍙樺悗鐨勫瓧絎﹂泦錛宻ource_char_set涓鴻瀛楃涓插師濮嬬殑瀛楃闆嗐?/p>

SELECT convert('涓浗','US7ASCII','ZHS16GBK') FROM dual;

4.4銆乺owidtochar(rowid)
璇存槑錛氬皢rowid杞崲涓哄搴旂殑varchar2鏁版嵁綾誨瀷鍊箋?/p>

4.5銆乼o_char()
select to_char(n’涓浗’) from dual; 杞彉涓烘湰鍦板瓧絎﹂泦綾誨瀷

select to_char(10000,’L99G999D99MI’) from dual; 杞崲鎴愯揣甯佹牸寮?/p>

4.6銆乼o_date()
杞彉涓烘棩鏈熸牸寮忋?/p>

4.7銆乼o_number()
灝嗗瓧絎︿覆杞彉涓烘暟瀛楀鹼紝浣嗗瓧絎︿覆蹇呴』鏄暟瀛?0~9)銆?/p>

鍗曡鍑芥暟

decode(exer.search1,result1[search2,result2,...][,defalut])
鐢ㄤ簬鍖歸厤鐗瑰畾琛ㄨ揪寮忕殑緇撴灉錛屽鏋渟earch1鍖歸厤浜巈xer錛屽垯榪斿洖result1錛屽鏋渟earch2鍖歸厤浜巈xer鍒欒繑鍥瀝esult2錛?br /> 渚濇綾繪帹錛屽鏋滄病鏈変換浣曞尮閰嶅叧緋誨垯榪斿洖defalut

鍒嗙粍鍑芥暟


6.1AVG 鍙栧鉤鍧囧?/span>
Select AVG(SAL) From EMP

6.2max 鍙栨渶澶у?/span>
select max(sal) from emp

6.3min 鍙栨渶灝忓?/span>
select min(sal) from emp

6.4count 鍙栬褰曟暟
SELECT COUNT(*) FROM EMP
涔熷彲浠?br /> select count(empno) from emp
娉ㄦ剰:
瑕佷箞count(*)
瑕佷箞count(娌℃湁null鍊肩殑鍒?--涓婚敭)

 

6.5sum 姹傚拰
Select SUM(SAL*12) From EMP

搴旂敤錛?/span>

1.鍒嗙粍鍑芥暟鍜宒istinct鍏抽敭璇嶇殑鎼厤
Select COUNT(Distinct SAL) From EMP

 

2.緇勫嚱鏁頒笌絀哄?br /> select count(comm) from emp
絀哄間笉鍙備笌榪愮畻,鐩存帴琚繃婊ゆ帀

 

3.鍒嗙粍鏁版嵁
group by瀛愬彞
SELECT COUNT(*) FROM EMP GROUP BY DEPTNO

4.浣跨敤group by瑙勫垯
A.group by鍚庨潰鐨勫瓧孌典笉蹇呮樉紺哄湪select鍒楄〃涓?br /> B.鍙嶄箣鍒欎笉琛?br /> 涔熷氨鏄:select鍚庨潰鐨勫瓧孌靛繀欏誨湪group by瀛愬彞涓嚭鐜?br /> 渚嬪鐨勬槸:
鍦ㄧ粍鍑芥暟(count,max,min絳?涓嚭鐜扮殑瀛楁闄ゅ

5.鍏充簬group by鏉′歡鍒嗙粍鐨勯棶棰?br /> A.group by鍙互鍜寃here鏉ユ惌閰?br /> where鍙兘鍦╣roup by鐨勫墠闈?br /> Select JOB From EMP Where SAL>2000 Group By JOB
group by鍚庨潰涓嶈兘鏈墂here

B.where瀛愬彞涓笉鑳藉寘鎷粍鍑芥暟
鏉′歡鐨勮〃杈懼彧鑳戒嬌鐢╤aving鏉ヨ〃紺?br /> Select DEPTNO,Max(SAL),Min(SAL) From EMP Group By DEPTNO Having Max(SAL)>2000

瀵硅薄鍑芥暟



junly 2010-07-28 18:22 鍙戣〃璇勮
]]>
oracle鍙橀噺http://www.tkk7.com/ywj-316/archive/2010/07/28/327301.htmljunlyjunlyWed, 28 Jul 2010 04:01:00 GMThttp://www.tkk7.com/ywj-316/archive/2010/07/28/327301.htmlhttp://www.tkk7.com/ywj-316/comments/327301.htmlhttp://www.tkk7.com/ywj-316/archive/2010/07/28/327301.html#Feedback0http://www.tkk7.com/ywj-316/comments/commentRss/327301.htmlhttp://www.tkk7.com/ywj-316/services/trackbacks/327301.html--1瀹氫箟鏍囬噺鍙橀噺
--
錛?錛夊畾涔夎娉?/span>
鍙橀噺鍚?nbsp;[constant] 鏁版嵁綾誨瀷 [not null] [:= | default expr]
-- constant:鐢ㄤ簬鎸囧畾甯擱噺銆傚繀欏繪寚瀹氬垵濮嬪?/span>
--
 := 鐢ㄤ簬涓哄彉閲忓拰甯擱噺鎸囧畾鍒濆鍊?/span>
--
 expr鍒濆鍊肩殑pl/sql琛ㄨ揪寮忥紝鍙互鏄枃鏈箋佸彉閲忋佸嚱鏁扮瓑
--
紺轟緥1錛?/span>
v_name varchar2(10);
v_rate constant 
number(3,2) := 5.5;
v_valid boolean 
not null default false;
--錛?錛変嬌鐢?/span>
--
鍙橀噺璧嬪間嬌鐢ㄧ瓑鍙峰墠鍔犲啋鍙鳳紙:=錛?/span>
--
紺轟緥2錛?/span>
declare
v_name 
varchar2(10);
v_money 
number(6,2);
c_tax_rate constant 
number(3,2) := -0.03;
v_tax_money 
number(6,2);
begin
 
select user_name,game_money into v_name,v_money 
 
from user_info where user_id = 100000;
 v_tax_money :
= v_money*c_tax_rate;
 dbms_output.put_line(
'name:'||v_name);
 dbms_output.put_line(
'money:'||v_money);
 dbms_output.put_line(
'rate:'||v_tax_money);
end
--錛?錛変嬌鐢?TYPE灞炴?/span>
v_name user_info.user_name%TYPE;
v_money user_info.game_money
%TYPE;
c_tax_rate constant 
number(3,2) := -0.03;
v_tax_money v_money
%TYPE;
--鍙橀噺v_name錛寁_money涓巙ser_info琛ㄧ殑user_name錛実ame_money鍒楃殑綾誨瀷鍜岄暱搴﹀畬鍏ㄤ竴鑷?/span>
--
鍙橀噺v_tax_money涓庡彉鏄痸_money鐨勭被鍨嬪拰闀垮害瀹屽叏涓鑷?/span>

--2澶嶅悎鍙橀噺
--
錛?錛塸l/sql璁板綍錛堢被浼間簬緇撴瀯錛?/span>
--
 鍦ㄥ畾涔夐儴鍒嗗畾涔夎褰曠被鍨嬪拰璁板綍鍙橀噺錛屽湪鎵ц閮ㄥ垎寮曠敤璇ヨ褰曞彉閲?/span>
--
 寮曠敤璁板綍鎴愬憳鏃跺繀欏昏鍔犺褰曞彉閲忎綔涓哄墠緙錛堣褰曞彉閲忋傝褰曟垚鍛橈級
--
紺轟緥3錛?/span>
declare
TYPE record_type 
IS RECORD(
  v_name user_info.
user_name%TYPE,
  v_money user_info.game_money
%TYPE
);
emp_record record_type;
begin
 
select user_name,game_money into emp_record 
 
from user_info where user_id = 100000;
 dbms_output.put_line(
'name:'||emp_record.v_name);
 dbms_output.put_line(
'money:'||emp_record.v_money);
end
--錛?錛塸l/sql琛紙綾諱技浜庢暟緇勶級
--
 pl/sql琛ㄤ笌鏁扮粍鍖哄埆錛氫笅鏍囨病鏈変笂涓嬮檺錛屼釜鏁板勾娌℃湁闄愬埗錛屼笅紲ㄥ彲浠ヤ負璐熷?/span>
--
 蹇呴』鍏堝湪瀹氫箟閮ㄥ垎瀹氫箟pl/sql琛ㄧ被鍨嬪拰pl/sql琛ㄥ彉閲忥紝鍦ㄦ墽琛岄儴鍒嗗紩鐢ㄨpl/sql琛ㄥ彉閲?/span>
--
紺轟緥4錛?/span>
declare
TYPE name_table_type 
IS TABLE OF user_info.user_name%TYPE 
  
INDEX BY BINARY_INTEGER;
v_name name_table_type;
begin
 
select user_name into v_name(-1
 
from user_info where user_id = 100000;
 dbms_output.put_line(
'name:'||v_name(-1));
end
--錛?錛夊祵濂楄〃
--
錛?錛塚ARRAY錛堝彉闀挎暟緇勶級

--3 鍙傜収鍙橀噺
--
 鐢ㄤ簬瀛樻斁鏁板兼寚閽堢殑鍙橀噺銆?/span>
--
錛?錛夋父鏍囧彉閲忥紙REF CURSOR錛?/span>
--
 闈欐佹父鏍囷細闇瑕佸湪瀹氫箟娓告爣鏃舵寚瀹氱浉搴旂殑select璇彞
--
 紺轟緥5錛?/span>
declare
  type c1 
is ref cursor;--c1涓簉ef cursor綾誨瀷
  emp_cursor c1;--emp_cursor涓烘父鏍囧彉閲?/span>
  v_name user_info.user_name%TYPE;
  v_money user_info.game_money
%TYPE;
begin
  
open emp_cursor for --鎵撳紑娓告爣鍙橀噺鏃舵寚瀹氫簡瀵瑰簲鐨剆elect璇彞
  select user_name,game_money from user_info where  user_id = 100000;
  loop
    
fetch emp_cursor into v_name,v_money;
    
exit when emp_cursor%notfound;
    dbms_output.put_line(v_name);
  
end loop;
end;
-- 鍔ㄦ佹父鏍囷細鍦ㄥ畾涔夋父鏍囧彉閲忔椂涓嶈闇鎸囧畾鐩稿簲鐨剆elect璇彞錛岃屾槸鎵撳紑娓告爣鏃舵寚瀹歴elect璇彞
--
錛?錛夊璞$被鍨嬪彉閲忥紙REF obj_type錛?/span>
--
 鏄寚鍚戝璞″疄渚嬬殑鎸囬拡
--
 紺轟緥6錛?/span>
create or replace type home_type as object(--寤虹珛瀵硅薄綾誨瀷
  street varchar2(50),city varchar2(20),
  state 
varchar2(20),zipcode varchar2(6),
  owner 
varchar2(10)
);
create table homes of home_type;--寤鴻〃
insert into homes values('涓婃搗璺?00鍙?/span>','涓婃搗','200000','junly');
commit;
--瀵硅薄琛╤omes瀛樻斁瀹跺涵鍦板潃鍙婃埛涓誨鍚嶏紝濡傛瘡涓搴湁鍥涘彛浜猴紝涓轟簡鍚屼竴瀹跺涵鎴愬憳鍏變韓瀹跺涵鍦板潃錛?/span>
--
鍙嬌鐢≧EF寮曠敤home_type瀵硅薄綾誨瀷錛屼粠鑰岄檷浣庡崰鐢ㄧ┖闂淬?/span>
create table person(
  id 
number(6primary key,
  name 
varchar2(10),
  addr ref home_type
);
insert into person select 1,'junly',ref(p) from homes p where p.owner='junly'
insert into person select 2,'junl2',ref(p) from homes p where p.owner='junly'
--person琛ㄦ彃鍏ユ暟鎹椂錛宎ddr鍒楀皢瀛樺叆鎸囧悜homes琛ㄧ浉搴旀暟鎹殑鍦板潃鎸囬拡

--4 LOB鍙橀噺
/*鐢ㄤ簬瀛樺偍澶ф壒閲忔暟鎹殑鍙橀噺
錛?錛夊唴閮↙OB
 CLOB    鏀妧浜嬪姟鎿嶄綔   瀛樺偍鏁版嵁搴撲腑   鐢ㄤ簬瀛樺偍澶ф壒閲忓瓧絎︽暟鎹?br />  BLOB    鏀妧浜嬪姟鎿嶄綔   瀛樺偍鏁版嵁搴撲腑   鐢ㄤ簬瀛樺偍澶ф壒閲忎簩榪涘埗鏁版嵁
 NCLOB   鏀妧浜嬪姟鎿嶄綔   瀛樺偍鏁版嵁搴撲腑   鐢ㄤ簬瀛樺偍澶ф壒閲忓瓧絎︽暟鎹?br /> 錛?錛夊閮↙OB
 BFILE   涓嶆敮鎶浜嬪姟     瀛樺湪OS鏂囦歡涓?nbsp;  瀛樺偍鎸囧悜OS鏂囦歡鐨勬寚閽?br />
*/


--5闈濸L/SQL鍙橀噺

junly 2010-07-28 12:01 鍙戣〃璇勮
]]>
sql 綺懼吀-oraclehttp://www.tkk7.com/ywj-316/archive/2010/07/28/327285.htmljunlyjunlyWed, 28 Jul 2010 01:46:00 GMThttp://www.tkk7.com/ywj-316/archive/2010/07/28/327285.htmlhttp://www.tkk7.com/ywj-316/comments/327285.htmlhttp://www.tkk7.com/ywj-316/archive/2010/07/28/327285.html#Feedback0http://www.tkk7.com/ywj-316/comments/commentRss/327285.htmlhttp://www.tkk7.com/ywj-316/services/trackbacks/327285.html

table:citys
city       ran

騫垮窞     A
騫垮窞     B
騫垮窞     C
騫垮窞     D

city        ran

騫垮窞     A,B,C,D

璇烽棶oracle  鐨剆ql璇彞瑕佹庝箞鍐?

select city,wmsys.wm_concat(ran)
from citys
group by city


2 澶囧繕

insert into emp (id,name,sex,tim) --dual
values(id_seq.nextval,'junly',default,to_date('2010-5-11 11:25:00','yyyy-mm-dd hh24:mi:ss'))


3 鐩存帴瑁呰澆

--鐩存帴瑁呰澆鏂瑰紡
insert /*+append*/ into emp (field1,field2,field3)
select f1,f2,f3 from tep
where f4=20;


4 鏇存柊

--鏇存柊
update emp set (field1,field2,field3)=(
select f1,f2,f3 from tep where f4=20)
where field4=100;

5 鍙栨秷閲嶅
select count(distinct user_nameas num
from user_info

6 group by + rollup 妯悜灝忚
-- group by + rollup 妯悜灝忚
select num1,sum(num2),sum(num3) from tmp_tb
group by rollup (num1)

7 group by + cube  綰靛悜灝忚
-- group by + cube  綰靛悜灝忚
select num1,sum(num2),sum(num3) from tmp_tb
group by cube(num1)

8 鑷繛鎺?br />
-- 鑷繛鎺?/span>
/* user_info
id    name    pid
-------------------
7888  king    
7889  blank   7888
7900  jones   7888
*/

select manager.name from user_info manager,user_info worker
where manager.id=worker.pid
and worker.name='jones';
----------
king

9 ALL鍜孉NY錛堜笉鑳藉崟鐙嬌鐢紝涓庡崟琛屾瘮杈冪錛?,>,<,>=,<=,<>錛界粨鍚堜嬌鐢級
--ALL鍜孉NY錛堜笉鑳藉崟鐙嬌鐢紝涓庡崟琛屾瘮杈冪錛?,>,<,>=,<=,<>錛界粨鍚堜嬌鐢級
/*
ALL 蹇呴』瑕佺鍚堝瓙鏌ヨ緇撴灉鐨勬墍鏈夊?br /> ANY 鍙絎﹀悎瀛愭煡璇㈢粨鏋滅殑浠諱竴涓煎嵆鍙?br />
*/

select user_name,money from user_info where money >all(
select money form user_game where id=10);
select user_name,money from user_info where money >any(
select money form user_game where id>10);

10 鍚堝茍鏌ヨ
--錛?錛塽nion 鍙栦袱涓粨鏋滈泦鐨勫茍闆嗭紝鑷姩鍘繪帀閲嶅琛屽茍浠ョ涓鍒楃殑緇撴灉鎺掑簭
--
錛?錛塽nion all 鍙栦袱涓粨鏋滈泦鐨勫茍闆嗭紝涓嶅幓閲嶅琛屼篃涓嶈繘琛屾帓搴?/span>
--
錛?錛塱ntersect 鍙栦袱涓粨鏋滈泦鐨勪氦闆?/span>
--
錛?錛塵inus 鍙栦袱涓粨鏋滈泦鐨勫樊闆?/span>
select uname,sal from emp where sal>200
union 
select uname,sal from emp where job='aaa'

11 case鏉′歡鍒嗘敮
select name,case when money>3000 then 3
when money>2000 then 2 when money>1000 then 1 end
from user_info where user_id=10000;

12 with瀛愬悕閲嶇敤瀛愭煡璇?br />
--with瀛愬悕閲嶇敤瀛愭煡璇?/span>
with summary as (
select name,sum(moneyas total from user_info
group by name
)
select name,total from summary 
where total>3000;

13 connect by (鎰熻阿騫垮窞Nicholas鍏?
select sysdate - rownum rn from dual connect by rownum<100
--鏃?/span>
select to_number(to_char(rn,'yyyymmdd'))rn from(select sysdate - rownum rn 
from dual connect by rownum<(
select floor(sysdate-regist_time)from sales_info where user_id=15587657))
--鏈堜喚
select to_number(to_char(rn,'yyyymm'))rn from(
select add_months(sysdate,-rownum) rn 
from dual connect by rownum<(
select floor(months_between(sysdate,regist_time)) from sales_info where user_id=15587657))

14 鎵圭悊淇敼
merge into sales_info s 
using tb_rd_user_info u
on (s.user_id=u.user_id)
when matched then
update
set s.user_name=u.user_name;
commit;

15 鍒犻櫎閲嶅璁板綍
delete from user where rowid in (
select max(rowid) from user group by userName having count(userName)>1)


junly 2010-07-28 09:46 鍙戣〃璇勮
]]>
oracle瀛樺偍榪囩▼,鍑芥暟,鍖?/title><link>http://www.tkk7.com/ywj-316/archive/2010/07/26/327159.html</link><dc:creator>junly</dc:creator><author>junly</author><pubDate>Mon, 26 Jul 2010 10:20:00 GMT</pubDate><guid>http://www.tkk7.com/ywj-316/archive/2010/07/26/327159.html</guid><wfw:comment>http://www.tkk7.com/ywj-316/comments/327159.html</wfw:comment><comments>http://www.tkk7.com/ywj-316/archive/2010/07/26/327159.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/ywj-316/comments/commentRss/327159.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/ywj-316/services/trackbacks/327159.html</trackback:ping><description><![CDATA[<div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /><span style="color: #008080">--</span><span style="color: #008080">渚?</span><span style="color: #008080"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">declare</span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />v_name </span><span style="font-weight: bold; color: #000000">varchar2</span><span style="color: #000000">(</span><span style="font-weight: bold; color: #800000">10</span><span style="color: #000000">);<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">begin</span><span style="color: #000000"> <br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /> </span><span style="color: #0000ff">select</span><span style="color: #000000"> </span><span style="color: #ff00ff">user_name</span><span style="color: #000000"> </span><span style="color: #0000ff">into</span><span style="color: #000000"> v_name </span><span style="color: #0000ff">from</span><span style="color: #000000"> tb_rd_user_info </span><span style="color: #0000ff">where</span><span style="color: #000000"> </span><span style="color: #ff00ff">user_name</span><span style="color: #808080">=</span><span style="color: #ff0000">'</span><span style="color: #ff0000">ywj12</span><span style="color: #ff0000">'</span><span style="color: #000000">;<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /> dbms_output.put_line(</span><span style="color: #ff0000">'</span><span style="color: #ff0000">name:</span><span style="color: #ff0000">'</span><span style="color: #808080">||</span><span style="color: #000000">v_name);<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />exception<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /> </span><span style="color: #0000ff">when</span><span style="color: #000000"> no_data_found </span><span style="color: #0000ff">then</span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /> dbms_output.put_line(</span><span style="color: #ff0000">'</span><span style="color: #ff0000">error name</span><span style="color: #ff0000">'</span><span style="color: #000000">);<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">end</span><span style="color: #000000">;<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #008080">--</span><span style="color: #008080">鍖垮悕鍧?/span><span style="color: #008080"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />--</span><span style="color: #008080">  娌℃湁鍚嶇О鐨刾l/sql鍧楋紝濡備緥1</span><span style="color: #008080"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />--</span><span style="color: #008080">鍛藉悕鍧?/span><span style="color: #008080"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />--</span><span style="color: #008080">瀛愮▼搴?/span><span style="color: #008080"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />--</span><span style="color: #008080">  (1)榪囩▼</span><span style="color: #008080"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />--</span><span style="color: #008080">     寤虹珛榪囩▼鏃跺彲浠ユ寚瀹氳緭鍏ュ弬鏁?in),杈撳嚭鍙傛暟(out)</span><span style="color: #008080"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">create</span><span style="color: #000000"> </span><span style="color: #808080">or</span><span style="color: #000000"> </span><span style="color: #ff00ff">replace</span><span style="color: #000000"> </span><span style="color: #0000ff">procedure</span><span style="color: #000000"> update_money(uname </span><span style="font-weight: bold; color: #000000">varchar2</span><span style="color: #000000">,num </span><span style="font-weight: bold; color: #000000">number</span><span style="color: #000000">)<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">is</span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">begin</span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">update</span><span style="color: #000000"> tb_rd_user_info </span><span style="color: #0000ff">set</span><span style="color: #000000"> game_money </span><span style="color: #808080">=</span><span style="color: #000000"> num <br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">where</span><span style="color: #000000"> </span><span style="color: #ff00ff">user_name</span><span style="color: #000000"> </span><span style="color: #808080">=</span><span style="color: #000000"> uname;<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">end</span><span style="color: #000000"> update_money;<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #008080">--</span><span style="color: #008080">     鍒犻櫎</span><span style="color: #008080"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">drop</span><span style="color: #000000">   </span><span style="color: #0000ff">procedure</span><span style="color: #000000">   update_money;<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #008080">--</span><span style="color: #008080">     璋冪敤</span><span style="color: #008080"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">exec</span><span style="color: #000000"> update_money(</span><span style="color: #ff0000">'</span><span style="color: #ff0000">ywj123</span><span style="color: #ff0000">'</span><span style="color: #000000">,</span><span style="font-weight: bold; color: #800000">100000</span><span style="color: #000000">);<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />call update_money(</span><span style="color: #ff0000">'</span><span style="color: #ff0000">ywj123</span><span style="color: #ff0000">'</span><span style="color: #000000">,</span><span style="font-weight: bold; color: #800000">100000</span><span style="color: #000000">);<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #008080">--</span><span style="color: #008080">     閲嶆柊緙栬瘧</span><span style="color: #008080"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">alter</span><span style="color: #000000"> </span><span style="color: #0000ff">procedure</span><span style="color: #000000"> update_money compile;<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #008080">--</span><span style="color: #008080">     鎺堟潈student鐢ㄦ埛浣跨敤璇ヨ繃紼?/span><span style="color: #008080"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">grant</span><span style="color: #000000"> </span><span style="color: #0000ff">execute</span><span style="color: #000000"> </span><span style="color: #0000ff">on</span><span style="color: #000000"> update_money </span><span style="color: #0000ff">to</span><span style="color: #000000"> student;  <br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #008080">--</span><span style="color: #008080">  (2)鍑芥暟</span><span style="color: #008080"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />--</span><span style="color: #008080">     鍒涘緩</span><span style="color: #008080"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">create</span><span style="color: #000000"> </span><span style="color: #808080">or</span><span style="color: #000000"> </span><span style="color: #ff00ff">replace</span><span style="color: #000000"> </span><span style="color: #0000ff">function</span><span style="color: #000000"> get_user_id(uname </span><span style="font-weight: bold; color: #000000">varchar2</span><span style="color: #000000">)<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">return</span><span style="color: #000000"> </span><span style="font-weight: bold; color: #000000">number</span><span style="color: #000000"> </span><span style="color: #0000ff">is</span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />  uid </span><span style="font-weight: bold; color: #000000">number</span><span style="color: #000000">;<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">begin</span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /> </span><span style="color: #0000ff">select</span><span style="color: #000000"> </span><span style="color: #ff00ff">user_id</span><span style="color: #000000"> </span><span style="color: #0000ff">into</span><span style="color: #000000"> uid </span><span style="color: #0000ff">from</span><span style="color: #000000"> tb_rd_user_info <br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /> </span><span style="color: #0000ff">where</span><span style="color: #000000"> </span><span style="color: #ff00ff">user_name</span><span style="color: #808080">=</span><span style="color: #000000">uname;<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /> </span><span style="color: #0000ff">return</span><span style="color: #000000"> uid;<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">end</span><span style="color: #000000">;<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #008080">--</span><span style="color: #008080">     璋冪敤</span><span style="color: #008080"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #ff00ff">var</span><span style="color: #000000"> rs </span><span style="font-weight: bold; color: #000000">number</span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />call get_user_id(</span><span style="color: #ff0000">'</span><span style="color: #ff0000">ywj123</span><span style="color: #ff0000">'</span><span style="color: #000000">) </span><span style="color: #0000ff">into</span><span style="color: #000000"> :rs;<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #008080">--</span><span style="color: #008080">     鍒犻櫎</span><span style="color: #008080"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">drop</span><span style="color: #000000"> </span><span style="color: #0000ff">function</span><span style="color: #000000"> get_user_id;<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #008080">--</span><span style="color: #008080">     閲嶆柊緙栬瘧</span><span style="color: #008080"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">alter</span><span style="color: #000000"> </span><span style="color: #0000ff">function</span><span style="color: #000000"> get_user_id compile錛?br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #008080">--</span><span style="color: #008080">  (3)鍖?/span><span style="color: #008080"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />--</span><span style="color: #008080">     鍒涘緩(鍖呯敱鍖呰鑼冨拰鍖呬綋涓ら儴鍒嗙粍鎴?</span><span style="color: #008080"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />--</span><span style="color: #008080">       鍖呰鑼?/span><span style="color: #008080"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">create</span><span style="color: #000000"> package emp_pkg </span><span style="color: #0000ff">is</span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />  </span><span style="color: #0000ff">procedure</span><span style="color: #000000"> update_money (uname </span><span style="font-weight: bold; color: #000000">varchar2</span><span style="color: #000000">,num </span><span style="font-weight: bold; color: #000000">number</span><span style="color: #000000">);<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />  </span><span style="color: #0000ff">function</span><span style="color: #000000"> get_user_id(uname </span><span style="font-weight: bold; color: #000000">varchar2</span><span style="color: #000000">) </span><span style="color: #0000ff">return</span><span style="color: #000000"> </span><span style="font-weight: bold; color: #000000">number</span><span style="color: #000000">;<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">end</span><span style="color: #000000">;<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #008080">--</span><span style="color: #008080">       鍖呬綋</span><span style="color: #008080"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">create</span><span style="color: #000000"> package body emp_pkg </span><span style="color: #0000ff">is</span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />  </span><span style="color: #0000ff">procedure</span><span style="color: #000000"> update_money(uname </span><span style="font-weight: bold; color: #000000">varchar2</span><span style="color: #000000">,num </span><span style="font-weight: bold; color: #000000">number</span><span style="color: #000000">)<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />  </span><span style="color: #0000ff">is</span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />  </span><span style="color: #0000ff">begin</span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />    </span><span style="color: #0000ff">update</span><span style="color: #000000"> tb_rd_user_info </span><span style="color: #0000ff">set</span><span style="color: #000000"> game_money </span><span style="color: #808080">=</span><span style="color: #000000"> num <br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />    </span><span style="color: #0000ff">where</span><span style="color: #000000"> </span><span style="color: #ff00ff">user_name</span><span style="color: #000000"> </span><span style="color: #808080">=</span><span style="color: #000000"> uname;<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />  </span><span style="color: #0000ff">end</span><span style="color: #000000"> update_money;<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />  <br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />  </span><span style="color: #0000ff">function</span><span style="color: #000000"> get_user_id(uname </span><span style="font-weight: bold; color: #000000">varchar2</span><span style="color: #000000">)<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />  </span><span style="color: #0000ff">return</span><span style="color: #000000"> </span><span style="font-weight: bold; color: #000000">number</span><span style="color: #000000"> </span><span style="color: #0000ff">is</span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />    uid </span><span style="font-weight: bold; color: #000000">number</span><span style="color: #000000">;<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />  </span><span style="color: #0000ff">begin</span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />    </span><span style="color: #0000ff">select</span><span style="color: #000000"> </span><span style="color: #ff00ff">user_id</span><span style="color: #000000"> </span><span style="color: #0000ff">into</span><span style="color: #000000"> uid </span><span style="color: #0000ff">from</span><span style="color: #000000"> tb_rd_user_info <br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />    </span><span style="color: #0000ff">where</span><span style="color: #000000"> </span><span style="color: #ff00ff">user_name</span><span style="color: #808080">=</span><span style="color: #000000">uname;<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />    </span><span style="color: #0000ff">return</span><span style="color: #000000"> uid;<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />  </span><span style="color: #0000ff">end</span><span style="color: #000000">;<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">end</span><span style="color: #000000">;<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #008080">--</span><span style="color: #008080">     璋冪敤</span><span style="color: #008080"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #000000">call emp_pkg.update_money(</span><span style="color: #ff0000">'</span><span style="color: #ff0000">ywj123</span><span style="color: #ff0000">'</span><span style="color: #000000">,</span><span style="font-weight: bold; color: #800000">100000</span><span style="color: #000000">);<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #ff00ff">var</span><span style="color: #000000"> rs </span><span style="font-weight: bold; color: #000000">number</span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />call emp_pkg.get_user_id(</span><span style="color: #ff0000">'</span><span style="color: #ff0000">ywj123</span><span style="color: #ff0000">'</span><span style="color: #000000">) </span><span style="color: #0000ff">into</span><span style="color: #000000"> :rs;<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #008080">--</span><span style="color: #008080">瑙e彂鍣?/span></div> <br /> <span style="color: red">瀛樺偍榪囩▼鍙傛暟浼犻?/span> <br /> <br /> 鍙傛暟鐨勪綔鐢ㄦ槸鍚戝瓨鍌ㄨ繃紼嬩紶閫掓暟鎹紝鎴栦粠瀛樺偍榪囩▼鑾峰緱榪斿洖緇撴灉銆傛紜殑浣跨敤鍙傛暟鍙互澶уぇ澧炲姞瀛樺偍榪囩▼鐨勭伒媧繪у拰閫氱敤鎬с?<br /> 鍙傛暟鐨勭被鍨嬫湁涓夌錛屽涓嬫墍紺恒?<br /> <pre class="sql" style="display: none" name="code"> <li><span><span id="imi2ee4" class="op">IN</span><span>  瀹氫箟涓涓緭鍏ュ弬鏁板彉閲忥紝鐢ㄤ簬浼犻掑弬鏁扮粰瀛樺偍榪囩▼   </span></span></li> <li><span id="u2o4kaq" class="keyword">OUT</span><span> 瀹氫箟涓涓緭鍑哄弬鏁板彉閲忥紝鐢ㄤ簬浠庡瓨鍌ㄨ繃紼嬭幏鍙栨暟鎹?  </span></span></li> <li><span id="2guyk4y" class="op">IN</span><span> </span><span id="kkeiasi" class="keyword">OUT</span><span>  瀹氫箟涓涓緭鍏ャ佽緭鍑哄弬鏁板彉閲忥紝鍏兼湁浠ヤ笂涓よ呯殑鍔熻兘 </span></pre> <br /> 鍙傛暟鐨勫畾涔夊艦寮忓拰浣滅敤濡備笅錛?<br /> 鍙傛暟鍚?IN 鏁版嵁綾誨瀷 DEFAULT 鍊鹼紱 <br /> 瀹氫箟涓涓緭鍏ュ弬鏁板彉閲忥紝鐢ㄤ簬浼犻掑弬鏁扮粰瀛樺偍榪囩▼銆傚湪璋冪敤瀛樺偍榪囩▼鏃訛紝涓葷▼搴忕殑瀹為檯鍙傛暟鍙互鏄父閲忋佹湁鍊煎彉閲忔垨琛ㄨ揪寮忕瓑銆侱EFAULT 鍏抽敭瀛椾負鍙夐」錛岀敤鏉ヨ瀹氬弬鏁扮殑榛樿鍊箋傚鏋滃湪璋冪敤瀛樺偍榪囩▼鏃朵笉鎸囨槑鍙傛暟錛屽垯鍙傛暟鍙橀噺鍙栭粯璁ゅ箋傚湪瀛樺偍榪囩▼涓紝杈撳叆鍙橀噺鎺ユ敹涓葷▼搴忎紶閫掔殑鍊鹼紝浣嗕笉鑳藉鍏惰繘琛岃祴鍊箋?<br /> 鍙傛暟鍚?OUT 鏁版嵁綾誨瀷錛?<br /> 瀹氫箟涓涓緭鍑哄弬鏁板彉閲忥紝鐢ㄤ簬浠庡瓨鍌ㄨ繃紼嬭幏鍙栨暟鎹紝鍗沖彉閲忎粠瀛樺偍榪囩▼涓繑鍥炲肩粰涓葷▼搴忋?<br /> 鍦ㄨ皟鐢ㄥ瓨鍌ㄨ繃紼嬫椂錛屼富紼嬪簭鐨勫疄闄呭弬鏁板彧鑳芥槸涓涓彉閲忥紝鑰屼笉鑳芥槸甯擱噺鎴栬〃杈懼紡銆傚湪瀛樺偍榪囩▼涓紝鍙傛暟鍙橀噺鍙兘琚祴鍊艱屼笉鑳藉皢鍏剁敤浜庤祴鍊鹼紝鍦ㄥ瓨鍌ㄨ繃紼嬩腑蹇呴』緇欒緭鍑哄彉閲忚嚦灝戣祴鍊間竴嬈°?<br /> 鍙傛暟鍚?IN OUT 鏁版嵁綾誨瀷 DEFAULT 鍊鹼紱 <br /> 瀹氫箟涓涓緭鍏ャ佽緭鍑哄弬鏁板彉閲忥紝鍏兼湁浠ヤ笂涓よ呯殑鍔熻兘銆傚湪璋冪敤瀛樺偍榪囩▼鏃訛紝涓葷▼搴忕殑瀹為檯鍙傛暟鍙兘鏄竴涓彉閲忥紝鑰屼笉鑳芥槸甯擱噺鎴栬〃杈懼紡銆侱EFAULT 鍏抽敭瀛椾負鍙夐」錛岀敤鏉ヨ瀹氬弬鏁扮殑榛樿鍊箋傚湪瀛樺偍榪囩▼涓紝鍙橀噺鎺ユ敹涓葷▼搴忎紶閫掔殑鍊鹼紝鍚屾椂鍙互鍙傚姞璧嬪艱繍綆楋紝涔熷彲浠ュ鍏惰繘琛岃祴鍊箋傚湪瀛樺偍榪囩▼涓繀欏葷粰鍙橀噺鑷沖皯璧嬪間竴嬈°?<br /> 濡傛灉鐪佺暐IN銆丱UT鎴朓N OUT錛屽垯榛樿妯″紡鏄疘N銆?nbsp;<br /> <div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /><span style="color: #0000ff">CREATE</span><span style="color: #000000"> </span><span style="color: #808080">OR</span><span style="color: #000000"> </span><span style="color: #ff00ff">REPLACE</span><span style="color: #000000"> </span><span style="color: #0000ff">PROCEDURE</span><span style="color: #000000"> CHANGE_SALARY(P_EMPNO </span><span style="color: #808080">IN</span><span style="color: #000000"> </span><span style="font-weight: bold; color: #000000">NUMBER</span><span style="color: #000000"> </span><span style="color: #0000ff">DEFAULT</span><span style="color: #000000"> </span><span style="font-weight: bold; color: #800000">7788</span><span style="color: #000000">,P_RAISE </span><span style="font-weight: bold; color: #000000">NUMBER</span><span style="color: #000000"> </span><span style="color: #0000ff">DEFAULT</span><span style="color: #000000"> </span><span style="font-weight: bold; color: #800000">10</span><span style="color: #000000">)<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />        </span><span style="color: #0000ff">AS</span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />         V_ENAME </span><span style="font-weight: bold; color: #000000">VARCHAR2</span><span style="color: #000000">(</span><span style="font-weight: bold; color: #800000">10</span><span style="color: #000000">);<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />V_SAL </span><span style="font-weight: bold; color: #000000">NUMBER</span><span style="color: #000000">(</span><span style="font-weight: bold; color: #800000">5</span><span style="color: #000000">);<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />        </span><span style="color: #0000ff">BEGIN</span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />         </span><span style="color: #0000ff">SELECT</span><span style="color: #000000"> ENAME,SAL </span><span style="color: #0000ff">INTO</span><span style="color: #000000"> V_ENAME,V_SAL </span><span style="color: #0000ff">FROM</span><span style="color: #000000"> EMP </span><span style="color: #0000ff">WHERE</span><span style="color: #000000"> EMPNO</span><span style="color: #808080">=</span><span style="color: #000000">P_EMPNO;<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />         </span><span style="color: #0000ff">UPDATE</span><span style="color: #000000"> EMP </span><span style="color: #0000ff">SET</span><span style="color: #000000"> SAL</span><span style="color: #808080">=</span><span style="color: #000000">SAL</span><span style="color: #808080">+</span><span style="color: #000000">P_RAISE </span><span style="color: #0000ff">WHERE</span><span style="color: #000000"> EMPNO</span><span style="color: #808080">=</span><span style="color: #000000">P_EMPNO;<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />         DBMS_OUTPUT.PUT_LINE(</span><span style="color: #ff0000">'</span><span style="color: #ff0000">闆囧憳</span><span style="color: #ff0000">'</span><span style="color: #808080">||</span><span style="color: #000000">V_ENAME</span><span style="color: #808080">||</span><span style="color: #ff0000">'</span><span style="color: #ff0000">鐨勫伐璧勮鏀逛負</span><span style="color: #ff0000">'</span><span style="color: #808080">||</span><span style="color: #000000">TO_CHAR(V_SAL</span><span style="color: #808080">+</span><span style="color: #000000">P_RAISE));<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">COMMIT</span><span style="color: #000000">;<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />        EXCEPTION<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />         </span><span style="color: #0000ff">WHEN</span><span style="color: #000000"> OTHERS </span><span style="color: #0000ff">THEN</span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />         DBMS_OUTPUT.PUT_LINE(</span><span style="color: #ff0000">'</span><span style="color: #ff0000">鍙戠敓閿欒錛屼慨鏀瑰け璐ワ紒</span><span style="color: #ff0000">'</span><span style="color: #000000">);<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />         </span><span style="color: #0000ff">ROLLBACK</span><span style="color: #000000">;<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />        </span><span style="color: #0000ff">END</span><span style="color: #000000">;</span></div> </li> 鍙傛暟鐨勫肩敱璋冪敤鑰呬紶閫掞紝浼犻掔殑鍙傛暟鐨勪釜鏁般佺被鍨嬪拰欏哄簭搴旇鍜屽畾涔夌殑涓鑷淬傚鏋滈『搴忎笉涓鑷達紝鍙互閲囩敤浠ヤ笅璋冪敤鏂規硶銆傚涓婁緥錛屾墽琛岃鍙ュ彲浠ユ敼涓猴細 <br />  EXECUTE CHANGE_SALARY(P_RAISE=>80,P_EMPNO=>7788); <br />   鍙互鐪嬪嚭浼犻掑弬鏁扮殑欏哄簭鍙戠敓浜嗗彉鍖栵紝騫朵笖鏄庣‘鎸囧嚭浜嗗弬鏁板悕鍜岃浼犻掔殑鍊鹼紝=>榪愮畻絎﹀乏渚ф槸鍙傛暟鍚嶏紝鍙充晶鏄弬鏁拌〃杈懼紡錛岃繖縐嶈祴鍊兼柟娉曠殑鎰忎箟杈冩竻妤氥?<br /> <img src ="http://www.tkk7.com/ywj-316/aggbug/327159.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/ywj-316/" target="_blank">junly</a> 2010-07-26 18:20 <a href="http://www.tkk7.com/ywj-316/archive/2010/07/26/327159.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>sql鎬濊礬http://www.tkk7.com/ywj-316/archive/2009/12/10/305400.htmljunlyjunlyThu, 10 Dec 2009 03:55:00 GMThttp://www.tkk7.com/ywj-316/archive/2009/12/10/305400.htmlhttp://www.tkk7.com/ywj-316/comments/305400.htmlhttp://www.tkk7.com/ywj-316/archive/2009/12/10/305400.html#Feedback0http://www.tkk7.com/ywj-316/comments/commentRss/305400.htmlhttp://www.tkk7.com/ywj-316/services/trackbacks/305400.html 

 select b.promo_number,b.payment_time,b.validity_days,a.tim,b.goods_name,b.payment_time+b.validity_days from 
        (
select max(m.send_time) tim 
        
from tb_payment_promo_log p,tb_mobile_log m  
        
where p.goods_id=615732 and p.user_name='ywj123' 
        
and p.promo_number=m.operate 
        
and   p.user_name = m.user_name ) a , tb_payment_promo_log b,tb_mobile_log c 
        
where b.goods_id=615732 and b.user_name='ywj123' and   b.user_name = c.user_name  and a.tim = c.send_time
        
order by b.payment_time desc

select t3.usid,t3.usname,t3.usarea,t3.cell from 
(
select  t2.cellphone cell,max(t1.game_money+t1.bank_game_money) money,t1.user_id usid,t1.user_name usname,t1.user_area usarea from tb_rd_user_info t1,tb_rd_user_info2 t2
where t1.login_tim <= sysdate-7 and t1.login_tim > sysdate-8 and t1.user_id = t2.user_id and t2.cellphone is not null
group by t2.cellphone,t1.user_id,t1.user_name,t1.user_area) t3 
where t3.money < 500000


junly 2009-12-10 11:55 鍙戣〃璇勮
]]>
閰嶆暟鎹簱鐨勬柟寮?/title><link>http://www.tkk7.com/ywj-316/archive/2009/11/30/304214.html</link><dc:creator>junly</dc:creator><author>junly</author><pubDate>Mon, 30 Nov 2009 01:45:00 GMT</pubDate><guid>http://www.tkk7.com/ywj-316/archive/2009/11/30/304214.html</guid><wfw:comment>http://www.tkk7.com/ywj-316/comments/304214.html</wfw:comment><comments>http://www.tkk7.com/ywj-316/archive/2009/11/30/304214.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/ywj-316/comments/commentRss/304214.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/ywj-316/services/trackbacks/304214.html</trackback:ping><description><![CDATA[1 jndi<br /> 閰嶇疆鏁版墍婧? <div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /><span style="color: #0000ff"><</span><span style="color: #800000">context:property-placeholder </span><span style="color: #ff0000">location</span><span style="color: #0000ff">="jdbc.properties"</span><span style="color: #0000ff">/></span><span style="color: #000000">//寮曞叆璧勬簮鏂囦歡<br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />    </span><span style="color: #0000ff"><</span><span style="color: #800000">bean </span><span style="color: #ff0000">id</span><span style="color: #0000ff">="datasource"</span><span style="color: #ff0000"> class</span><span style="color: #0000ff">="org.apache.commons.dbcp.BasicDataSource"</span><span style="color: #ff0000"> destroy-method</span><span style="color: #0000ff">="close"</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />            </span><span style="color: #0000ff"><</span><span style="color: #800000">property </span><span style="color: #ff0000">name</span><span style="color: #0000ff">="driverClassName"</span><span style="color: #ff0000"> value</span><span style="color: #0000ff">="org.git.mm.mysql.Driver[${driverClassName}]"</span><span style="color: #0000ff">/></span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />            </span><span style="color: #0000ff"><</span><span style="color: #800000">property </span><span style="color: #ff0000">name</span><span style="color: #0000ff">="url"</span><span style="color: #ff0000"> value</span><span style="color: #0000ff">="jdbc:mysql://localhost:3306/database?useUnicode=true &amp; characterEncoding=UTF-8[${url}]"</span><span style="color: #0000ff">/></span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />            </span><span style="color: #0000ff"><</span><span style="color: #800000">property </span><span style="color: #ff0000">name</span><span style="color: #0000ff">="username"</span><span style="color: #ff0000"> value</span><span style="color: #0000ff">="root[${username}]"</span><span style="color: #0000ff">/></span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />            </span><span style="color: #0000ff"><</span><span style="color: #800000">property </span><span style="color: #ff0000">name</span><span style="color: #0000ff">="password"</span><span style="color: #ff0000"> value</span><span style="color: #0000ff">="root[${password}]"</span><span style="color: #0000ff">/></span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />            </span><span style="color: #008000"><!--</span><span style="color: #008000"> 榪炴帴姹犲惎鍔ㄦ椂鐨勫垵濮嬪煎嫟 </span><span style="color: #008000">--></span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />            </span><span style="color: #0000ff"><</span><span style="color: #800000">property </span><span style="color: #ff0000">name</span><span style="color: #0000ff">="initialSize"</span><span style="color: #ff0000"> value</span><span style="color: #0000ff">="1[${initialSize}]"</span><span style="color: #0000ff">/></span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />            </span><span style="color: #008000"><!--</span><span style="color: #008000"> 榪炴帴姹犵殑鏈澶у?nbsp;</span><span style="color: #008000">--></span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />            </span><span style="color: #0000ff"><</span><span style="color: #800000">property </span><span style="color: #ff0000">name</span><span style="color: #0000ff">="maxActive"</span><span style="color: #ff0000"> value</span><span style="color: #0000ff">="500[${maxActive}]"</span><span style="color: #0000ff">/></span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />            </span><span style="color: #008000"><!--</span><span style="color: #008000"> 鏈澶х┖闂插鹼紝褰撶粡榪囦竴涓珮宄版椂闂村悗錛岃繛鎺ユ睜鍙互鎱㈡參灝嗗凡緇忕敤涓嶅埌鐨勮繛鎺ラ噴鏀句竴閮ㄥ垎,涓鐩村噺灝戝埌maxIdle涓烘 </span><span style="color: #008000">--></span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />            </span><span style="color: #0000ff"><</span><span style="color: #800000">property </span><span style="color: #ff0000">name</span><span style="color: #0000ff">="maxIdle"</span><span style="color: #ff0000"> value</span><span style="color: #0000ff">="2[${maxIdle}]"</span><span style="color: #0000ff">/></span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />            </span><span style="color: #008000"><!--</span><span style="color: #008000"> 鏈灝忕┖闂插鹼紝褰撹繛鎺ユ睜鐨勮繛鎺ユ暟閲忓皯浜庨榾鍊兼椂,榪炴帴姹犲氨浼氱敵璇蜂竴浜涜繛鎺?浠ュ厤媧嘲鏃舵潵涓嶅強鐢寵 </span><span style="color: #008000">--></span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />            </span><span style="color: #0000ff"><</span><span style="color: #800000">property </span><span style="color: #ff0000">name</span><span style="color: #0000ff">="minIdle"</span><span style="color: #ff0000"> value</span><span style="color: #0000ff">="1[${minIdle}]"</span><span style="color: #0000ff">/></span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />        </span><span style="color: #0000ff"></</span><span style="color: #800000">bean</span><span style="color: #0000ff">></span></div> 2 bean <div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /><span style="color: #0000ff"><</span><span style="color: #800000">bean </span><span style="color: #ff0000">id</span><span style="color: #0000ff">="datasource"</span><span style="color: #ff0000"> class</span><span style="color: #0000ff">="org.apache.commons.dbcp.BasicDataSource"</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />        </span><span style="color: #0000ff"><</span><span style="color: #800000">property </span><span style="color: #ff0000">name</span><span style="color: #0000ff">="driverClassName"</span><span style="color: #ff0000"> value</span><span style="color: #0000ff">="com.microsoft.sqlserver.jdbc.SQLServerDriver"</span><span style="color: #0000ff">/></span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />        </span><span style="color: #0000ff"><</span><span style="color: #800000">property </span><span style="color: #ff0000">name</span><span style="color: #0000ff">="url"</span><span style="color: #ff0000"> value</span><span style="color: #0000ff">="jdbc:sqlserver://127.0.0.1:1433;databaseName=somken"</span><span style="color: #0000ff">/></span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />        </span><span style="color: #0000ff"><</span><span style="color: #800000">property </span><span style="color: #ff0000">name</span><span style="color: #0000ff">="username"</span><span style="color: #ff0000"> value</span><span style="color: #0000ff">="sa"</span><span style="color: #0000ff">/></span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />        </span><span style="color: #0000ff"><</span><span style="color: #800000">property </span><span style="color: #ff0000">name</span><span style="color: #0000ff">="password"</span><span style="color: #ff0000"> value</span><span style="color: #0000ff">="123456"</span><span style="color: #0000ff">/></span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /> </span><span style="color: #0000ff"></</span><span style="color: #800000">bean</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />    <br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />    </span><span style="color: #0000ff"><</span><span style="color: #800000">bean </span><span style="color: #ff0000">id</span><span style="color: #0000ff">="sf"</span><span style="color: #ff0000"> class</span><span style="color: #0000ff">="org.springframework.orm.hibernate3.LocalSessionFactoryBean"</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />        </span><span style="color: #0000ff"><</span><span style="color: #800000">property </span><span style="color: #ff0000">name</span><span style="color: #0000ff">="dataSource"</span><span style="color: #ff0000"> ref</span><span style="color: #0000ff">="datasource"</span><span style="color: #0000ff">/></span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />        <br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />        </span><span style="color: #0000ff"><</span><span style="color: #800000">property </span><span style="color: #ff0000">name</span><span style="color: #0000ff">="mappingResources"</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />            </span><span style="color: #0000ff"><</span><span style="color: #800000">list</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />                </span><span style="color: #0000ff"><</span><span style="color: #800000">value</span><span style="color: #0000ff">></span><span style="color: #000000">org/somken/entity/UserInfo.xml</span><span style="color: #0000ff"></</span><span style="color: #800000">value</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />            </span><span style="color: #0000ff"></</span><span style="color: #800000">list</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />        </span><span style="color: #0000ff"></</span><span style="color: #800000">property</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />        <br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />        </span><span style="color: #0000ff"><</span><span style="color: #800000">property </span><span style="color: #ff0000">name</span><span style="color: #0000ff">="hibernateProperties"</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />            </span><span style="color: #0000ff"><</span><span style="color: #800000">props</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />                </span><span style="color: #0000ff"><</span><span style="color: #800000">prop </span><span style="color: #ff0000">key</span><span style="color: #0000ff">="hibernate.dialect"</span><span style="color: #0000ff">></span><span style="color: #000000">org.hibernate.dialect.SQLServerDialect</span><span style="color: #0000ff"></</span><span style="color: #800000">prop</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />                </span><span style="color: #0000ff"><</span><span style="color: #800000">prop </span><span style="color: #ff0000">key</span><span style="color: #0000ff">="hibernate.show_sql"</span><span style="color: #0000ff">></span><span style="color: #000000">true</span><span style="color: #0000ff"></</span><span style="color: #800000">prop</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />            </span><span style="color: #0000ff"></</span><span style="color: #800000">props</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />        </span><span style="color: #0000ff"></</span><span style="color: #800000">property</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />    </span><span style="color: #0000ff"></</span><span style="color: #800000">bean</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span></div> 3 璇誨彇hibernate.cfg.xml <div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /><span style="color: #0000ff"><</span><span style="color: #800000">bean </span><span style="color: #ff0000">id</span><span style="color: #0000ff">="sf"</span><span style="color: #ff0000"> class</span><span style="color: #0000ff">="org.springframework.orm.hibernate3.LocalSessionFactoryBean"</span><span style="color: #0000ff">></span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" />          </span><span style="color: #0000ff"><</span><span style="color: #800000">property </span><span style="color: #ff0000">name</span><span style="color: #0000ff">="configLocation"</span><span style="color: #ff0000"> value</span><span style="color: #0000ff">="classpath:hibernate.cfg.xml"</span><span style="color: #0000ff">/></span><span style="color: #000000"><br /> <img src="http://www.tkk7.com/images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff"></</span><span style="color: #800000">bean</span><span style="color: #0000ff">></span></div> <img src ="http://www.tkk7.com/ywj-316/aggbug/304214.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/ywj-316/" target="_blank">junly</a> 2009-11-30 09:45 <a href="http://www.tkk7.com/ywj-316/archive/2009/11/30/304214.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>BaseDAOhttp://www.tkk7.com/ywj-316/archive/2009/11/30/304202.htmljunlyjunlyMon, 30 Nov 2009 00:21:00 GMThttp://www.tkk7.com/ywj-316/archive/2009/11/30/304202.htmlhttp://www.tkk7.com/ywj-316/comments/304202.htmlhttp://www.tkk7.com/ywj-316/archive/2009/11/30/304202.html#Feedback0http://www.tkk7.com/ywj-316/comments/commentRss/304202.htmlhttp://www.tkk7.com/ywj-316/services/trackbacks/304202.html
package org.epet.dao.impl;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;

import com.sun.java_cup.internal.internal_error;

public abstract class BaseDAO {
    
private static final String DRIVER_CLASS = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
    
private static final String DATABASE_URL = "jdbc:sqlserver://localhost:1433;DatabaseName=epet";
    
private static final String DATABASE_USER = "sa";
    
private static final String DATABASE_PASSWORD = "accp";
    
    
/**
     * 榪斿洖榪炴帴
     * 
@return
     
*/

    
public static Connection getConnection() {
        Connection connection
=null;
        
try {
            Class.forName(DRIVER_CLASS);
            connection 
= DriverManager.getConnection(DATABASE_URL,
                    DATABASE_USER, DATABASE_PASSWORD);
//                Context tx=new InitialContext();
//                DataSource ds=(DataSource)tx.lookup("java:comp/env/food");
//                connection=ds.getConnection();

        }
 catch (SQLException e) {
            e.printStackTrace();
        }
 catch (ClassNotFoundException e) {
            
// TODO Auto-generated catch block
            e.printStackTrace();
        }

        
return connection;
    }

    
/**
     * 鏌ヨ
     * 
@param sql
     * 
@return
     
*/

    
public static ResultSet getDate(String sql){
        Connection connection
=getConnection();
        ResultSet resultSet
=null;
        
try {
            PreparedStatement preparedStatement
=connection.prepareStatement(sql);
            resultSet
=preparedStatement.executeQuery();
        }
 catch (SQLException e) {
            e.printStackTrace();
        }

        
return resultSet;
    }

    
    
public static int dele(String sql,int id){
        
int result=0;
        Connection connection
=getConnection();
        
try {
            PreparedStatement preparedStatement
=connection.prepareStatement(sql);
            preparedStatement.setInt(
1, id);
            result
=preparedStatement.executeUpdate();
        }
 catch (SQLException e) {
            e.printStackTrace();
        }

        
return result;
    }

}

mysql:
/*show databases;
create database aa;
use aa;
show tables;
select * from userinfo limit 1,2;
-----------------------------------------
*/

public connection getConnection () throws SQLException{
  Class.forName(
"com.mysql.jdbc.Driver");
  String url
="jdbc:mysql://127.0.1:3306/somken(鏁版嵁搴撳悕)";
  
return DriverManager.getConnection(url,"root","root");
}


junly 2009-11-30 08:21 鍙戣〃璇勮
]]>
sql閰嶇疆鏂囨。http://www.tkk7.com/ywj-316/archive/2009/11/29/304133.htmljunlyjunlySun, 29 Nov 2009 13:22:00 GMThttp://www.tkk7.com/ywj-316/archive/2009/11/29/304133.htmlhttp://www.tkk7.com/ywj-316/comments/304133.htmlhttp://www.tkk7.com/ywj-316/archive/2009/11/29/304133.html#Feedback0http://www.tkk7.com/ywj-316/comments/commentRss/304133.htmlhttp://www.tkk7.com/ywj-316/services/trackbacks/304133.html1銆佽緗?/span>SQL Server鏈嶅姟鍣細

1-1銆?#8220;SQL Server 2005 鏈嶅姟”涓仠姝㈡湇鍔?#8220;SQL Server 錛?/span>SQLEXPRESS錛?#8221;錛堥粯璁ゆ槸鍚姩鐘舵侊級

1-2銆?#8220;SQL Server 2005 緗戠粶閰嶇疆” MSSQLSERVER 鐨勫崗璁?#8221;錛屽惎鍔?#8220;TCP/IP”錛堥粯璁ゆ槸紱佺敤鐘舵侊級錛岀劧鍚庡弻鍑?#8220;TCP/IP”榪涘叆灞炴ц緗紝鍦?#8220;IP 鍦板潃”閲岋紝紜“IPAll

涓殑“TCP 绔彛”涓?/span>1433

1-3銆?#8220;SQL Server 2005 鏈嶅姟”涓惎鍔ㄦ湇鍔?#8220;SQL Server 錛?/span>MSSQLSERVER 錛?#8221;錛堥粯璁ゆ槸鍋滄鐘舵侊級

1-4銆佸叧闂?#8220;SQL Server Configuration Manager”錛堟鏃跺彲浠ュ惎鍔?#8220;SQL Server Management Studio”錛屽茍鐢ㄥ笎鎴?/span>sa銆佸瘑鐮?/span>123鐧誨綍錛?/span>SQL Server鏈嶅姟鍣ㄨ緗紜殑璇濆簲璇ヨ兘鐧誨綍鎴愬姛錛?/span>

2銆佸鍏?/span>jar鍖咃細

鎵撳紑Test鐨?#8220;Properties Java Build Path Libraries Add External JARs 錛岄夋嫨涓嬭澆濂界殑榪炴帴椹卞姩鍖?#8220;sqljdbc.jar”錛岀劧鍚庣偣鍑?#8220;OK”紜畾

3濡傛灉浣犱互鍓嶇敤JDBC榪炴帴SQL Server 2000鐨勮瘽灝?span style="color: red">瑕佹敞鎰忎簡錛?/span>

鍦?/span>SQL Server 2000 涓姞杞介┍鍔ㄥ拰URL璺緞鐨勮鍙ユ槸

“com.microsoft.jdbc.sqlserver.SQLServerDriver”
jdbc:microsoft:sqlserver://localhost:1433; DatabaseName=JSPTest”

鑰?/span>SQL Server 2005 涓姞杞介┍鍔ㄥ拰URL鐨勮鍙ュ垯涓?/span>

“com.microsoft.sqlserver.jdbc.SQLServerDriver”

jdbc:sqlserver://localhost:1433; DatabaseName=JSPTest”

娉ㄦ剰涓よ呯殑宸紓

junly 2009-11-29 21:22 鍙戣〃璇勮
]]>
mysql_urlhttp://www.tkk7.com/ywj-316/archive/2009/11/03/300944.htmljunlyjunlyTue, 03 Nov 2009 09:43:00 GMThttp://www.tkk7.com/ywj-316/archive/2009/11/03/300944.htmlhttp://www.tkk7.com/ywj-316/comments/300944.htmlhttp://www.tkk7.com/ywj-316/archive/2009/11/03/300944.html#Feedback0http://www.tkk7.com/ywj-316/comments/commentRss/300944.htmlhttp://www.tkk7.com/ywj-316/services/trackbacks/300944.html

junly 2009-11-03 17:43 鍙戣〃璇勮
]]>
PL/SQL Developer 瀵煎叆瀵煎嚭csv鏂囦歡http://www.tkk7.com/ywj-316/archive/2009/11/02/300663.htmljunlyjunlyMon, 02 Nov 2009 04:01:00 GMThttp://www.tkk7.com/ywj-316/archive/2009/11/02/300663.htmlhttp://www.tkk7.com/ywj-316/comments/300663.htmlhttp://www.tkk7.com/ywj-316/archive/2009/11/02/300663.html#Feedback0http://www.tkk7.com/ywj-316/comments/commentRss/300663.htmlhttp://www.tkk7.com/ywj-316/services/trackbacks/300663.htmlPL/SQL Developer 鍙互瀵煎叆鎴栬呭鍑篊SV鏂囦歡銆?/p>

 瀵煎叆CSV鏂囦歡姝ラ錛?/p>

 1銆侀夋嫨tools->text importer....

 2銆侀夋嫨絎簩涓狣ata to oracle閫夐」鍗★紝鐒跺悗閫夋嫨Open Data file....錛岄夋嫨瑕佸鍏ョ殑csv鏂囦歡錛岀‘瀹?/p>

 3銆侀夋嫨瀵瑰簲鐨刼wner鍜宼able錛屽皢瀛楁涓涓瀵瑰簲錛屾渶鍚庣偣鍑諱笅鏂圭殑瀵煎叆錛屾暟鎹嵆瀵煎叆鍒頒簡閫夊畾鐨則able涓簡銆?/p>

   

瀵煎嚭csv鏂囦歡鐩稿姣旇緝綆鍗曪細

1銆佸厛鐢╯ql璇彞鏌ヨ寰楀埌緇撴灉

2銆侀夋嫨export query results .....閫夋嫨淇濆瓨涓篶sv鏂囦歡鍗沖彲銆?/p>

 

鏈枃鏉ヨ嚜CSDN鍗氬錛岃漿杞借鏍囨槑鍑哄錛歨ttp://blog.csdn.net/lovingprince/archive/2009/03/11/3979833.aspx



junly 2009-11-02 12:01 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 中文亚洲成a人片在线观看| 曰批全过程免费视频网址| 另类小说亚洲色图| 亚洲精品乱码久久久久久V| 91在线亚洲综合在线| 国产精品高清视亚洲精品| 亚洲国产日韩在线成人蜜芽 | 亚洲毛片在线免费观看| 99爱免费观看视频在线| 最好看的中文字幕2019免费| 97免费人妻在线视频| 99精品视频在线观看免费专区| 无码成A毛片免费| 91精品国产免费久久国语麻豆| www.免费在线观看| 99热在线精品免费全部my| 桃子视频在线观看高清免费完整| 色婷婷7777免费视频在线观看| 性xxxxx免费视频播放 | 国产福利免费视频| 国产成人无码精品久久久免费 | 精品日韩99亚洲的在线发布| 久久综合久久综合亚洲| 亚洲成av人片在线天堂无| 国产亚洲精品2021自在线| 免费一区二区无码视频在线播放| 黄色短视频免费看| 日本免费人成视频在线观看| 无码国产精品一区二区免费| 日本特黄特色免费大片| 亚洲一区二区三区免费| 亚洲av之男人的天堂网站| 亚洲精品视频在线观看免费 | 亚洲av永久无码精品漫画| 67pao强力打造67194在线午夜亚洲 | 无码国产精品一区二区免费vr| 国产精品免费观看| 国产乱弄免费视频| 亚洲人色婷婷成人网站在线观看| 91情国产l精品国产亚洲区| 亚洲中文字幕无码久久2020|