OracleÖÐͳ¼ÆÆõºÏijÁÐÌõ¼þµÄÁÐ×ܺÍ
×î½üÔÚÏîÄ¿±¨±íÖÐÐèÒªÒ»¸ö²éѯÓï¾ä£¬ÓÃÀ´Í³¼Æ·ûºÏijһÁÐÌõ¼þµÄÆäËü¼¸ÁеĸöÊý
±ÈÈçÓÐÏÂÃæÒ»¸ö±í½á¹¹£º
ÐèÒªÔÚÁÐDºóÃæÔö¼ÓÒ»ÁУ¬Í³¼ÆÔÚÁÐA²»Îª¿Õ£¬²¢ÇÒÁÐB¡¢C¡¢D²»Îª¿ÕµÄ¸öÊý
¾¹ý×Ô¼ºÊÔÑ飬²éÕÒ°ïÖú£¬×ÜËãʵÏÖÁËÉÏÃæµÄ²éѯ¡£
Ê×ÏȽ²¼¸¸öº¯ÊýµÄÓ÷¨£º
NULL£ºÖ¸µÄÊÇ¿ÕÖµ£¬»òÕß·Ç·¨Öµ¡£
NVL (expr1, expr2)
²ÎÊý˵Ã÷£ºÈç¹ûexpr1ΪNULL£¬·µ»Øexpr2£»²»ÎªNULL£¬·µ»Øexpr1¡£×¢ÒâÁ½ÕßµÄÀàÐÍÒªÒ»ÖÂ
NVL2 (expr1, expr2, expr3)
²ÎÊý˵Ã÷£ºÈç¹ûexpr1²»ÎªNULL£¬·µ»Øexpr2£»ÎªNULL£¬·µ»Øexpr3¡£expr2ºÍexpr3ÀàÐͲ»Í¬µÄ»°£¬expr3»áת»»Îªexpr2µÄÀàÐÍ
NULLIF (expr1, expr2)
²ÎÊý˵Ã÷£ºÈç¹ûÏàµÈ·µ»ØNULL£¬²»µÈ·µ»Øexpr1
ÏÂÃæÊDZ¾ÈËͨ¹ýÁ½ÖÖ·½·¨ÊµÏֵĽá¹û
·½·¨Ò»£º
´úÂë
1 Select a,
2 b,
3 c,
4 d,
5 Case
6 When a Is Not Null Then
7 Nvl2(b, 1,0) + Nvl2(c, 1,0) + Nvl2(d, 1,0)
8 Else
9 0
10 End E
11 from AA
·½·¨¶þ£º
´úÂë
1 Select a,
2 b,
3 c,
4
Ïà¹ØÎĵµ£º
1.¶à°æ±¾£º¶ÁÒ»Ö²éѯ ·Ç×èÈû²éѯ
Oracle ²ÉÓÃÁËÒ»ÖÖ
¶à°æ±¾¡¢¶ÁÒ»Ö£¨read-consistent£©µÄ²¢·¢Ä£ÐÍ¡£ÔÙ´Î˵Ã÷£¬ÎÒÃǽ«ÔÚµÚ7 Õ¸üÏêϸµØ½éÉÜÓйصļ¼Êõ¡£
²»¹ý£¬ÊµÖÊÉϽ²£¬Oracle ÀûÓÃÕâÖÖ»úÖÆÌṩÁËÒÔÏÂÌØÐÔ£º
¶ÁÒ»Ö²éѯ£º¶ÔÓÚÒ»¸öʱ¼äµã£¨point in time£©£¬²éѯ»á²úÉúÒ»ÖµĽá¹û¡£
·Ç×èÈû²éѯ£º²éѯ²»» ......
°Ñ×Ô¼ºËѼ¯µÄ×ÊÁÏÌù³öÀ´£¬Ñ§Ï°¹¤×÷·½±ãÕ¼¡£
SQLÖеĵ¥¼Ç¼º¯Êý
1.ASCII
·µ»ØÓëÖ¸¶¨µÄ×Ö·û¶ÔÓ¦µÄÊ®½øÖÆÊý;
SQL> select ascii('A') A,ascii('a') a,ascii('0') zero,ascii(' ') space from dual;
A A ZERO SPACE
--------- --------- --------- ---------
65 97 48 32
2.CHR
¸ø³öÕûÊý,·µ»Ø¶ÔÓ¦µÄ×Ö·û;
SQ ......
sqlplusµÄÅäÖÃÎļþΪlogin.sql£¬Í¨³£ÈçÏÂËùʾ´´½¨¸ÃÎļþ£º
set serveroutput on size 1000000
set trimspool on --Â˳ýspoolÊä³öµÄ¿Õ°×
set linesize 200 --ÓÃÓÚÉ趨ÿÐÐÏÔʾµÄ¿í¶È
set pagesize 9999 --ÉèÖÃÏÔʾµÄÒ³Êý
set sqlprompt '_user @ _connect_identifier> '
½«¸ÃÎļþ¸´ÖƵ½Oracle°²×°Ä¿Â¼C ......
1.ÔÚOracle ÖУ¬Äã»áÁ˽⵽£º
ÊÂÎñÊÇÿ¸öÊý¾Ý¿âµÄºËÐÄ£¬ËüÃÇÊÇ“ºÃ¶«Î÷”¡£
Ó¦¸ÃÑÓ³Ùµ½Êʵ±µÄʱ¿Ì²ÅÌá½»¡£²»ÒªÌ«¿ìÌá½»£¬ÒÔ±ÜÃâ¶Ôϵͳ´øÀ´Ñ¹Á¦¡£ÕâÊÇÒòΪ£¬Èç¹û
ÊÂÎñºÜ³¤»òºÜ´ó£¬Ò»°ã²»»á¶ÔϵͳÓÐѹÁ¦¡£ÏàÓ¦µÄÔÔòÊÇ£ºÔÚ±ØҪʱ²ÅÌá½»£¬µ«ÊÇ´ËÇ°²»ÒªÌá
½»¡£ÊÂÎñµÄ´óСֻӦ¸Ã¸ù¾ÝÒµÎñÂß¼À´¶¨¡£
Ö»ÒªÐèÒ ......
ORACLE
CREATE OR REPLACE FUNCTION SETSTATE(OLDVALUE VARCHAR2, POS NUMBER, SVALUE VARCHAR2)
RETURN VARCHAR2
IS
RETURN_VALUE VARCHAR2 (20);
LEN NUMBER(8);
I NUMBER(8);
TEMP_VALUE VARCHAR2(1);
BEGIN
LEN := LENGTH(OLDVALUE);
IF POS > ......