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

PL/SQL ¿ØÖƽṹ

ÔÚPL/SQLÖÐÒýÈëÁË¿ØÖƽṹ£¬°üÀ¨Ñ¡Ôñ½á¹¹£¬Ñ­»·½á¹¹ºÍÌøת½á¹¹
Ò» Ñ¡Ôñ½á¹¹
1,IF Óï¾ä
 
    ÔÚPL/SQLÖУ¬Ñ¡Ôñ½á¹¹¿ÉÒÔͨ¹ýifÓï¾äÀ´ÊµÏÖ£¬Ò²¿ÉÒÔͨ¹ýCaseÓï¾ä£¨oracle9iÖУ©
    ÀûÓÃifÓï¾äʵÏÖÑ¡Ôñ¿ØÖƵÄÓ﷨Ϊ£º
     if condition1 then statements1;
     [else if condition2 then statements2;]
     ......
    [else  else_statements];
    end if;
 
  ÓÉÓÚPL/SQL ÖеÄÂß¼­ÔËËã½á¹ûÓÐtrue,false ºÍnull ÈýÖÖ£¬Òò´ËÔÚ½øÐÐÑ¡ÔñÌõ¼þµÄÅжÏʱ£¬Òª¿¼ÂÇÌõ¼þΪnullµÄÇé¿ö
 
 
2,CASE Óï¾ä
 
 ÔÚOracle9iÖÐÌṩÁËÁíÒ»ÖÖÑ¡Ôò¿ØÖƽṹ£¬¼´caseÓï¾ä¡£case Óï¾äÓÐÁ½ÖÖÐÎʽ£¬Ò»ÖÖÖ»½øÐеÈÖµ±È½Ï£¬ÁíÒ»ÖÖ¿ÉÒÔ½øÐжàÌõ¼þ±È½Ï¡£
£¨1£©Ö»½øÐеÈÖµ±È½ÏµÄcaseÓï¾ä£»
   Case test_value
          when value1 then statements1;
          when value2 then statements2;
          ......
         when valuen then statementsn;
         [else  else_statements;]
        end case;
 case Óï¾äÅжÏtest_value µÄÖµÊÇ·ñÓëvalueÖµÏàµÈ¡£Èç¹ûÏàµÈ£¬ÔòÖ´ÐÐÆäºóµÄÓï¾ä¡£
£¨2£© ¿ÉÒÔ¶àÌõ¼þ±È½Ïcase Óï¾ä
   case
       when condition1 then statements1;
       when condition2 then statements2;
       ......
       when conditionn then statementn;
        [ else else_statements;]
      end case;
    case Óï¾ä¶Ôÿһ¸öwhenÌõ¼þ½øÐÐÅжϣ¬µ±Ìõ¼þΪÕæʱ£¬Ö´ÐÐÆäºóµÄÓï¾ä£»Èç¹ûËùÓеÄÌõ¼þ¶¼Îª¼Ù£¬ÔòÖ´ÐÐelseºóµÄÓï¾ä¡£
¶þ Ñ­»·Óï¾ä
ÔÚPL/SQLÖУ¬Ñ­»·½á¹¹ÓÐÈýÖÖÐÎʽ£¬·Ö±ðΪ¼òµ¥Ñ­»·£¬whileÑ­»·£¬forÑ­»·¡£
1&nbs


Ïà¹ØÎĵµ£º

SqlÁ¬½Ó²éѯºÍÁªºÏ²éѯ


SqlÁ¬½Ó²éѯºÍÁªºÏ²éѯ
Á¬½Ó²éѯ
   ͨ¹ýÁ¬½ÓÔËËã·û¿ÉÒÔʵÏÖ¶à¸ö±í²éѯ¡£Á¬½ÓÊǹØϵÊý¾Ý¿âÄ£Ð͵ÄÖ÷ÒªÌص㣬ҲÊÇËüÇø±ðÓÚÆäËüÀàÐÍÊý¾Ý¿â¹ÜÀíϵͳµÄÒ»¸ö±êÖ¾¡£
   ÔÚ¹ØϵÊý¾Ý¿â¹ÜÀíϵͳÖУ¬±í½¨Á¢Ê±¸÷Êý¾ÝÖ®¼äµÄ¹Øϵ²»±ØÈ·¶¨£¬³£°ÑÒ»¸öʵÌåµÄËùÓÐÐÅÏ¢´æ·ÅÔÚÒ»¸ö±íÖС£µ±¼ìË÷Êý¾Ýʱ£¬Í¨¹ýÁ¬½Ó²Ù×÷² ......

ÔÚpl/sql ÖиıäÁ㤶È

 
    
 
NO.1  
alter   table   pdt   modify("PDTNAME",varchar2(100))
NO.2  
×ֶβ»ÓÓ”  
  alter   table   pdt   modify(PDTNAME,varchar2(100)) &n ......

OracleµÄSQLÓï¾äÖÐÈçºÎ´¦Àí¡®&¡¯·ûºÅ

ÔÚOracleÖУ¬Èç¹ûÔÚsqlÖгöÏÖ'&'·ûºÅ£¬»á±»×Ô¶¯×ªÒ壻
¶ø±»ÒªÇóÊäÈëÔÚ&·ûºÅºó¸úËæµÄ×Ö·û´®µÄÖµ£¬ÀýÈ磺
update tablename set columnName='http://www.g.cn/cv2.jsp?spid=222&cid=333';
Ö´ÐÐÕâ¸ö²Ù×÷ʱ£¬Oracle»áÌáʾ
Enter value for cid:
Ô­ÒòÊÇÔÚOracleÖÐ & ·ûºÅÊÇ×÷ΪתÒå×Ö·ûʹÓõġ£
½â¾ö·½·¨ ......

×ݱíתºá±íµÄ"SQL"ʾÀý£º

×ݱíתºá±íµÄ"SQL"ʾÀý£º
¡¡¡¡×ݱí½á¹¹:
¡¡¡¡
¡¡¡¡fname ftype fvalue
¡¡¡¡Ð¡ÇÇ zaocan 10
¡¡¡¡Ð¡ÇÇ zhongcan 20
¡¡¡¡Ð¡ÇÇ wancan 5
¡¡¡¡
¡¡¡¡×ª»»ºóµÄ±í½á¹¹:
¡¡¡¡
¡¡¡¡fname zaocan_value zhongcan_value wancan_value
¡¡¡¡Ð¡ÇÇ 10 20 5
¡¡¡¡
¡¡¡¡×ݱíתºá±íSQLʾÀý:
¡¡¡¡
¡¡¡¡select Fname, sum(case ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ