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

OracleÊý¾Ý¿â×Ô¶¨ÒåÒì³£µÄʹÓ÷½·¨

 À´Ô´£º²»Ïê  ×÷ÕߣºØýÃû  Ê±¼ä£º2009-9-6 17:14:04 Tags£º Orac ʹÓ÷½·¨
ÐèÇó£ºÒµÎñÂß¼­ÔÚ´¦ÀíÊý¾Ýʱ£¬ÐèÒª·µ»ØMessage²¢×èÖ¹³ÌÐòµÄ¼ÌÐøÔËÐС£µ«ÊÇ£¬ÔÚ´æ´¢¹ý³ÌʹÓÃOracleÊý¾Ý¿âµÄRaise¸ù±¾ÎÞ·¨Âú×ãÏÖÔÚµÄÒªÇó¡£
½â¾ö·½·¨£º
ʹÓÃRAISE_APPLICATION_ERROR
RAISE_APPLICATION_ERROR ( error_number_in IN NUMBER, error_msg_in IN VARCHAR2);
error_number: ×Ô¶¨ÒåµÄ´íÎó±àºÅ¡£
error_msg£º×Ô¶¨ÒåµÄ´íÎóÄÚÈÝ¡£
ÔÚʹÓõĹý³ÌÖУ¬Äã¿ÉÄÜ»áÓöµ½ÁËÏÂÃæµÄÎÊÌâ¡£
ORA-21000: error number argument to raise_application_error of [xxxx] is out of range
³öÏÖ´Ë´íÎóµÄÔ­ÒòÈçÏ£º
ÔÚ´æ´¢¹ý³ÌÖж¨ÒåµÄ´íÎó´úÂëNumberÆäʵ²¢²»ÔÚOracleÊý¾Ý¿âËùÔÊÐíµÄ·¶Î§Ö®ÄÚ¡£ÒòΪOracleÊý¾Ý¿âÔÊÐí×Ô¶¨ÒåµÄ´íÎó´úÂëµÄ·¶Î§ÊÇ-20000 -- -20999
 
ÕâÑù£¬¾ÍÔÚJava¶Ë¿ÉÒÔͨ¹ýSQLExceptionÀ´²¶»ñÒì³£¡£
ËäȻͨ¹ýSQLException.getMessage()¿ÉÒÔ²¶»ñµ½Òì³£µÄÄÚÈÝ£¬µ«ÊÇÕâЩÄÚÈݶÔÓÚ¿ª·¢±È½ÏÓÐÓ᣶ÔÓÚ¿Í»§À´Ëµ£¬²¢²»ÓѺã¬Ò²Ã»Óжà´óÒâÒå¡£
ͨ¹ýSQLException.getErrorCode()¿ÉÒÔ²¶»ñµ½×Ô¶¨ÒåµÄÒì³£´íÎó±àºÅ¡£È»ºóÎÒÃǾͿÉÒÔͨ¹ýÕâ¸ö´íÎó±àºÅ£¬×Ô¶¨ÒåÏàÓ¦µÄMessageÄÚÈÝ£¬·µ»Ø¸ø¿Í»§¡£
 
ÏÂÃæÎÒÃÇÀ´½éÉÜÁíÒ»ÖÖ½â¾ö·½·¨£º
ͨ¹ý´æ´¢¹ý³Ì·µ»ØÖµ£¬Äã¿ÉÒÔÖ±½Ó°Ñ´íÎóMessage¶¨ÒåÔÚ·µ»ØÖµÖм䡣ÔÚJava¶Ë½âÎöºó£¬¿ÉÒÔÖ±½ÓÈ¡µÃMessage´úÂë¡£
ʾÀýÈçÏ£º
If condition then
 
p_result := 'ERR:MSG2061';
end if;
 
if substr(p_result, 1, 3) = 'ERR' then
ROLLBACK;
else
p_result = 'OK';
end if;
 
Java£ºÂÔÈ¥ÖмäµÄµ÷Óô洢¹ý³ÌµÄ²½Öè
if(result != null && result.startsWith("ERR:"))
// ´ÓresultÖнâÎö³öMessage_id£¬ÏÔʾMessageµ½Ç°Ì¨


Ïà¹ØÎĵµ£º

oracle ´æ´¢¹ý³Ì

 select myFunc(²ÎÊý1,²ÎÊý2..) to dual; --¿ÉÒÔÖ´ÐÐһЩҵÎñÂß¼­
Ò»:OracleÖеĺ¯ÊýÓë´æ´¢¹ý³ÌµÄÇø±ð:
A:º¯Êý±ØÐëÓзµ»ØÖµ,¶ø¹ý³ÌûÓÐ.
B:º¯Êý¿ÉÒÔµ¥¶ÀÖ´ÐÐ.¶ø¹ý³Ì±ØÐëͨ¹ýexecuteÖ´ÐÐ.
C:º¯Êý¿ÉÒÔǶÈëµ½SQLÓï¾äÖÐÖ´ÐÐ.¶ø¹ý³Ì²»ÐÐ.
ÆäʵÎÒÃÇ¿ÉÒÔ½«±È½Ï¸´ÔӵIJéѯд³Éº¯Êý.È»ºóµ½´æ´¢¹ý³ÌÖÐÈ¥µ÷ÓÃÕâЩº¯Êý.
¶þ:È ......

oracle ÖеÄminus

 minusÔËËã
·µ»ØÔÚµÚÒ»¸ö²éѯ½á¹ûÖÐÓëµÚ¶þ¸ö²éѯ½á¹û²»ÏàͬµÄÄDz¿·ÖÐмǼ¡£
ÓÐÄÄЩ¹¤ÖÖÔڲƻᲿÖÐÓУ¬¶øÔÚÏúÊÛ²¿ÖÐûÓУ¿
exp:selectjobfromaccount
minus
selectjobfromsales;
ÓëunionÏà·´ ......

Oracle SQLÓï¾ä

ORDER BY ÅÅÐò
 
ASC ÉýÐò(ĬÈÏ)
 DESC ½µÐò
 
select * from s_emp order by dept_id , salary desc
²¿ÃźÅÉýÐò£¬¹¤×ʽµÐò
¹Ø¼ü×ÖdistinctÒ²»á´¥·¢ÅÅÐò²Ù×÷¡£
 
select * from employee order by 1; //°´µÚÒ»×Ö¶ÎÅÅÐò
NULL±»ÈÏΪÎÞÇî´ó¡£order by ¿ÉÒÔ¸ú±ðÃû¡£
 
select table_name ......

ORACLE²åÈëÈÕÆÚÊý¾Ý

 oracleÊý¾Ý¿â²åÈëÈÕÆÚÐÍÊý¾Ý
ÍùOracleÊý¾Ý¿âÖвåÈëÈÕÆÚÐÍÊý¾Ý£¨to_dateµÄÓ÷¨£©
INSERT  INTO  FLOOR  VALUES  ( to_date ( '2007-12-20 18:31:34' , 'YYYY-MM-DD HH24:MI:SS' ) ) ;
²éѯÏÔʾ£º2007-12-20 18:31:34.0
-------------------
INSERT  INTO  FLOOR  VALUES ......

ORACLE OMF½éÉÜ

ÏÈ¿´Oracle ¹Ù·½½âÊÍ
Oracle managed file (OMF)
A file that is created automatically by the Oracle database server when it is needed and automatically deleted when it is no longer needed.
 
ÈçºÎÅжÏÄãµÄÊý¾Ý¿âÊÇ·ñΪ֧³ÖOMF
SQL> show parameter db_create_file_dest;
 
NAME  & ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ