oracleµÄdecode
DECODEº¯ÊýµÄ×÷ÓãºËü¿ÉÒÔ½«ÊäÈëÊýÖµÓ뺯ÊýÖеIJÎÊýÁбíÏà±È½Ï£¬¸ù¾ÝÊäÈëÖµ·µ»ØÒ»¸ö¶ÔÓ¦Öµ¡£º¯ÊýµÄ²ÎÊýÁбíÊÇÓÉÈô¸ÉÊýÖµ¼°Æä¶ÔÓ¦½á¹ûÖµ×é³ÉµÄÈô¸ÉÐòżÐÎʽ¡£µ±È»£¬Èç¹ûδÄÜÓëÈκÎÒ»¸öʵ²ÎÐòżƥÅä³É¹¦£¬Ôòº¯ÊýÒ²ÓÐĬÈϵķµ»ØÖµ¡£
¡¡¡¡Çø±ðÓÚSQLµÄÆäËüº¯Êý£¬DECODEº¯Êý»¹ÄÜʶ±ðºÍ²Ù×÷¿ÕÖµ¡£
¡¡¡¡Óï·¨ÈçÏ£º
¡¡¡¡DECODE(control_value,value1,result1[,value2,result2…][,default_result]);
¡¡¡¡control _value
¡¡¡¡ÊÔͼ´¦ÀíµÄÊýÖµ¡£DECODEº¯Êý½«¸ÃÊýÖµÓëºóÃæµÄһϵÁеÄżÐòÏà±È½Ï£¬ÒÔ¾ö¶¨·µ»ØÖµ¡£
¡¡¡¡value1
¡¡¡¡ÊÇÒ»×é³ÉÐòżµÄÊýÖµ¡£Èç¹ûÊäÈëÊýÖµÓë֮ƥÅä³É¹¦£¬ÔòÏàÓ¦µÄ½á¹û½«±»·µ»Ø¡£¶ÔÓ¦Ò»¸ö¿ÕµÄ·µ»ØÖµ£¬¿ÉÒÔʹÓùؼü×ÖNULLÓÚÖ®¶ÔÓ¦
¡¡¡¡result1
¡¡¡¡ÊÇÒ»×é³ÉÐòżµÄ½á¹ûÖµ¡£
¡¡¡¡default_result δÄÜÓëÈκÎÒ»¸öֵƥÅäʱ£¬º¯Êý·µ»ØµÄĬÈÏÖµ¡£
¡¡¡¡Ê¾ÀýÈçÏ£º
¡¡¡¡select decode( x , 1 , ‘x is 1 ’, 2 , ‘x is 2 ’, ‘others’) from dual
¡¡¡¡µ±xµÈÓÚ1ʱ£¬Ôò·µ»Ø‘x is 1’¡£
¡¡¡¡µ±xµÈÓÚ2ʱ£¬Ôò·µ»Ø‘x is 2’¡£
¡¡¡¡·ñÔò£¬·µ»Øothers’¡£
¡¡¡¡ÔÚÐèÒª±È½Ï2¸öÖµµÄʱºò£¬ÎÒÃÇ¿ÉÒÔÅäºÏSIGN()º¯ÊýÒ»ÆðʹÓá£
¡¡¡¡SELECT DECODE( SIGN(5 -6), 1 'Is Positive', -1, 'Is Nagative', 'Is Zero')
¡¡¡¡Í¬Ñù£¬Ò²¿ÉÒÔÓÃCASEʵÏÖ£º
¡¡¡¡SELECT CASE SIGN(5 - 6)
¡¡¡¡WHEN 1 THEN 'Is Positive'
¡¡¡¡WHEN¡¡-1 THEN 'Is Nagative'
¡¡¡¡ELSE¡¡'Is Zero' END
¡¡¡¡from DUAL
¡¡¡¡ÁíÍ⣬´ó¼Ò»¹¿ÉÒÔÔÚOrder byÖÐʹÓÃDecode¡£
¡¡¡¡Àý£º±ítable_subject£¬ÓÐsubject_nameÁС£ÒªÇó°´ÕÕ£ºÓï¡¢Êý¡¢ÍâµÄ˳Ðò½øÐÐÅÅÐò¡£Õâʱ£¬¾Í¿ÉÒԷdz£ÇáËɵÄʹÓÃDecodeÍê³ÉÒªÇóÁË¡£
¡¡¡¡select * from table_subject order by decode(subject_name, 'ÓïÎÄ', 1, 'Êýѧ', 2, , 'ÍâÓï',3)
Ïà¹ØÎĵµ£º
oracle¶ÔʱÇøµÄÖ§³Ö±È½ÏÍêÃÀÁË£¬ÓÐtimestamp with time zoneºÍtimestamp with local time zoneÁ½ÖÖÊý¾ÝÀàÐÍ¡£Ëùνtimestamp with time zone£¬Ò²¾ÍÊÇ°ÑʱÇøÐÅÏ¢±£´æÔÚÁÐÊý¾ÝÖУ¬¶øtimestamp with local time zone£¬»á½«Óû§ÊäÈëµÄʱ¼äת»»ÎªÊý¾Ý¿â·þÎñÆ÷ËùÔÚʱÇøµÄʱ¼ä£¬±£´æÔÚÁÐÖУ¬ÕâÑùÄÜÉÔÉÔ¼õÉÙÒ»µã±£´æµÄÊý¾ÝÁ¿¡£ÒòΪt ......
ѧϰOracleʱ£¬Äã¿ÉÄÜ»áÓöµ½oracle±í¿Õ¼ä»Ö¸´ÎÊÌ⣬ÕâÀォ½éÉÜOracle±í¿Õ¼ä»Ö¸´ÎÊÌâµÄ½â¾ö·½·¨£¬ÔÚÕâÀïÄóöÀ´ºÍ´ó¼Ò·ÖÏíһϡ£
Oracle±í¿Õ¼ä»Ö¸´·½°¸
Ò».Óû§±í¿Õ¼ä
´íÎó:
ÔÚÆô¶¯Êý¾Ý¿âʱ³öÏÖora-01157,ora-01110»ò²Ù×÷ϵͳ¼¶´íÎóÀýÈçora-07360, ÔڹرÕÊý¾Ý¿â(ʹÓÃshutdown normal»òshutdown immediate) ʱ½«µ¼Ö´íÎó ......
Êý¾Ý¿â½á¹¹ºÍ¿Õ¼ä¹ÜÀí£¨Êý¾ÝÎļþ¡¢ÈÕÖ¾Îļþ¡¢±í¿Õ¼ä¡¢¶Î¡¢Ä£Ê½ºÍģʽ¶ÔÏó£©
Ò»¸öORACLEÊý¾Ý¿âÊÇÊý¾ÝµÄ¼¯ºÏ,±»´¦Àí³ÉÒ»¸öµ¥Î»¡£Ò»¸öORACLEÊý¾Ý¿âÓÐÒ»¸öÎïÀí½á¹¹ºÍÒ»¸öÂß¼½á¹¹¡£
ORACLEÂß¼Êý¾Ý¿â½á¹¹ÊÇÓû§ËùÉæ¼°µÄÊý¾Ý¿â½á¹¹¡£Ò»¸öORACLEÊý¾Ý¿âµÄÂß¼½á¹¹ÓÉÏÂÁÐÒòËؾö¶¨:
&nb ......
³£ÓÃSQL²éѯ£º
1¡¢²é¿´±í¿Õ¼äµÄÃû³Æ¼°´óС
select t.tablespace_name, round(sum(bytes/(1024*1024)),0) ts_size
from dba_tablespaces t, dba_data_files d
where t.tablespace_name = d.tablespace_name
group by t.tablespace_name;
2¡¢²é¿´±í¿Õ¼äÎïÀíÎļþµÄÃû³Æ¼°´óС
select tablespace_name, file_id, ......
OracleÊý¾Ýµ¼Èëµ¼³öimp/exp¾ÍÏ൱ÓÚoracleÊý¾Ý»¹ÔÓ뱸·Ý¡£expÃüÁî¿ÉÒÔ°ÑÊý¾Ý´ÓÔ¶³ÌÊý¾Ý¿â·þÎñÆ÷µ¼³öµ½±¾µØµÄdmpÎļþ£¬impÃüÁî¿ÉÒÔ°ÑdmpÎļþ´Ó±¾µØµ¼Èëµ½Ô¶´¦µÄÊý¾Ý¿â·þÎñÆ÷ÖС£ ÀûÓÃÕâ¸ö¹¦ÄÜ¿ÉÒÔ¹¹½¨Á½¸öÏàͬµÄÊý¾Ý¿â£¬Ò»¸öÓÃÀ´²âÊÔ£¬Ò»¸öÓÃÀ´ÕýʽʹÓá£
Ö´Ðл·¾³£º¿ÉÒÔÔÚSQLPLUS.EXE»òÕßDOS£¨ÃüÁîÐУ©ÖÐÖ´Ð ......