0
 45   5   1
  View Articles

Name  
   ¼Õº´¸ñ  (2002-03-20 21:27:15, Hit : 13814, Vote : 1208)
Homepage  
   http://www.itmembers.net
Subject  
   ¿À¶óŬ µ¥ÀÌÅÍ °Ë»ö - Scalar Function(2) ¹®ÀÚÇü ÇÔ¼ö
Áö³­ ½Ã°£À» ÅëÇØ ´À³¢¼ÌµíÀÌ Scalar ÇÔ¼ö´Â ±×¸® ¾î·ÆÁö ¾Ê½À´Ï´Ù.
ÇÔ¼ö À̸§¸¸À¸·Îµµ ±× ¶æÀÌ ÁüÀÛÀÌ µÇ°í »ç¿ë¹ýµµ ±×¸® º¹ÀâÇÏÁö ¾Ê½À´Ï´Ù.
¿À´ÃÀº Áö³­ ½Ã°£¿¡ ÀÌ¾î ¹®ÀÚÇü ÇÔ¼ö¿¡ ´ëÇØ ±× Á¾·ù¸¦ °£·«ÇÏ°Ô ¾Ë¾Æº¸°í °£´ÜÇÑ ½Ç½ÀÀ» Çغ¸µµ·Ï ÇÏ°Ú½À´Ï´Ù.


  1. ¹®ÀÚÇü ÇÔ¼öÀÇ Á¾·ù



  2. UPPER, LOWER, INITCAP ÇÔ¼ö
    ¹é¹®ÀÌ ºÒ¿©ÀÏŸ, ÀÏ´Ü ÀÔ·ÂÇØ º¸°í ±× °á°ú¸¦ º¾½Ã´Ù.
    SQL*Plus¸¦ ½ÇÇàÇؼ­ ´ÙÀ½ ¹®ÀåÀ» Á÷Á¢ ÀÔ·ÂÇØ º¸¼¼¿ä.
    SELECT EMP_NUM,
        LOWER(LAST_NAME),
        INITCAP(FIRST_NAME),
        UPPER(ADDRESS)
    FROM EMP;



  3. CONCAT ÇÔ¼ö
    ¹®ÀÚ¿­ ÇÕ¼º ÇÔ¼ö¶ó°í ÇßÁÒ?
    Á÷Á¢ Çѹø Çغ¸¼¼¿ä.

    SELECT CONCAT( LAST_NAME, FIRST_NAME )
    FROM        EMP;


    ¼º°ú À̸§ÀÌ ¸ðµÎ ºÙ¾î¼­ Ãâ·ÂµË´Ï´Ù.

    ±×·³ ÀÌ·¸°Ô Çغ¸¸é ¾î¶³±î¿ä?
    SELECT CONCAT(FIRST_NAME, '´Ô' )
    FROM EMP;

    Á÷Á¢ ±× °á°ú¸¦ È®ÀÎÇØ º¸¼¼¿ä.

  4. SUBSTR ÇÔ¼ö
    ÀÌ°Ç Á¶±Ý ¼³¸í µå·Á¾ß°Ú³×¿ä.
    ÀÏ´Ü
    SUBSTR(arg1, start_position, length)¿Í °°Àº Çü½ÄÀ¸·Î ¾²ÀÔ´Ï´Ù.
    ¿©±â¼­ arg1¿¡´Â Ä÷³ À̸§ÀÌ ¿É´Ï´Ù.
    start_positionÀÌ ¾ç¼öÀÌ¸é ¿ÞÂʺÎÅÍ ½ÃÀÛ, À½¼öÀÌ¸é ¿À¸¥ÂʺÎÅÍ ½ÃÀÛÇÏ¿© length Å©±â¸¸Å­ ¹®ÀÚ¿­À» ÀÚ¸¨´Ï´Ù. ¸¸¾à length¸¦ »ý·«ÇÏ¸é ³ª¸ÓÁö start_position¿¡¼­ ½ÃÀÛÇÏ¿© ³ª¸ÓÁö ¸ðµÎ¸¦ ÀÚ¸¨´Ï´Ù.

    ±×·³ ¾Æ·¡ ¹®ÀåÀ» Á÷Á¢ ÀÔ·ÂÇؼ­ ±× °á°ú¸¦ »ìÆì º¸¼¼¿ä.
    SELECT SUBSTR( LAST_NAME, 2, 3 )
    FROM EMP;


    ÀÌ·¸°Ô ÇÏ¸é ¶Ç ¾î¶³±î¿ä?
    SELECT SUBSTR( FIRST_NAME, -3)
    FROM        EMP;

    ±×³É FIRST_NAMEÀ» SELECTÇßÀ» ¶§¿Í ºñ±³ÇØ º¸¼¼¿ä.

  5. LENGTH ÇÔ¼ö
    ƯÁ¤ Ä÷³ÀÇ ±æÀ̸¦ ±¸Çϱâ À§ÇÑ ÇÔ¼öÀε¥, Çѱ۰ú ¿µ¹® ¸ðµÎ 1¹ÙÀÌÆ®·Î Ãë±ÞÇÕ´Ï´Ù.
    µ¥ÀÌÅÍÀÇ À¯Çüº°·Î LENGTH ÇÔ¼ö¸¦ Àû¿ëÇßÀ» ¶§ ±¸ÇÒ ¼ö ÀÖ´Â ±æÀÌ°¡ Á¶±Ý ´Ù¸¥µ¥,
    NUMBERÇü µ¥ÀÌÅͶó¸é ½ÇÁ¦ ±æÀ̸¦ ±¸ÇÏ°í
    DATEÇü µ¥ÀÌÅͶó¸é Default Date FormatÀÇ ±æÀ̸¦ ±¸ÇÕ´Ï´Ù.
    CHARÇüÀ̶ó¸é Á¤ÀÇµÈ ±æÀ̸¦ ±¸ÇÏ°í
    VARCHAR2ÇüÀ̶ó¸é Á¤ÀÇµÈ ±æÀÌ¿Í »ó°ü¾øÀÌ ½ÇÁ¦ ±æÀ̸¦ ±¸ÇÕ´Ï´Ù.
    LONG Çüµµ ½ÇÁ¦ ±æÀ̸¦ ±¸ÇÕ´Ï´Ù.

    ÀÚ, ½Ç½ÀÇØ º¼±î¿ä?
    SELECT LENGTH(EMP_NUM),
    LENGTH(ADDRESS)
    FROM EMP;


  6. LPAD/RPAD ÇÔ¼ö
    ¹®ÀÚ¿­ÀÇ ¿ÞÂÊ°ú ¿À¸¥ÂÊÀÇ °ø¹éÀ» ƯÁ¤ ÁöÁ¤ÇÑ ¹®ÀÚ¿­·Î ä¿ì´Âµ¥ ´ÙÀ½°ú °°ÀÌ »ç¿ëÇÕ´Ï´Ù.
    LPAD( arg1, length, arg2 )
    RPAD( arg1, length, arg2 )
    À̶§ arg1Àº Column NameÀ̳ª ¹®ÀÚ¿­À̾î¾ß ÇÏ°í,
    length´Â Àüü ÀÚ¸´¼ö¸¦ ³ªÅ¸³À´Ï´Ù.
    ä¿ì°íÀÚ ÇÏ´Â ¹®ÀÚ´Â arg2 ÀÚ¸®¿¡ ¾¹´Ï´Ù. ¸¸¾à »ý°½ÇÏ¸é °ø¹éÀ¸·Î ä¿öÁý´Ï´Ù.

    ¾Æ·¡¿Í °°ÀÌ ÀÔ·ÂÇÏ¸é ¾î¶² °á°ú°¡ ³ª¿Ã±î¿ä?
    SELECT LPAD( PLAY_TIME, 5, '*' ),
    RPAD(PLAY_TIME, 5, '*' )
    FROM VIDEO;

    ¿ä°Ç Á÷Á¢ Çѹø Çغ¸¼¼¿ä.

  7. LTRIM/RTRIM ÇÔ¼ö
    ÀÏ´Ü Çü½ÄºÎÅÍ º¾½Ã´Ù.
    LTRIM( arg1, arg2 )
    RTRIM( arg1, arg2 )
    arg1ÀÇ ¹®ÀÚ¿­¿¡¼­ ´õ ÀÌ»ó arg2ÀÇ ¹®ÀÚ¿­À» ¸¸³ªÁö ¾ÊÀ» ¶§±îÁö Áö¿î °á°ú¸¦ ±¸ÇÕ´Ï´Ù.
    À̶§ arg1Àº Column NameÀ̳ª ¹®ÀÚ¿­ÀÌ°í, arg2µµ ¹®ÀÚ¿­ÀÔ´Ï´Ù.

    ¾Æ·¡¿Í °°ÀÌ ÀÔ·ÂÇØ º¸¼¼¿ä.
    SELECT LTRIM( 'XXAXBA', 'X' ),
    RTRIM('XXAXBA' , 'A' )
    FROM DUAL;

    °á°ú°¡ ¿¹ÃøµË´Ï±î?
    LTRIMÀÇ °á°ú´Â AXBA, RTRIMÀÇ °á°ú´Â XXAXB°¡ µÇ°ÚÁÒ?

  8. TRANSLATE/REPLACE
    a ¹®ÀÚ¸¦ b¹®ÀÚ·Î ¹Ù²Ù°í ½Í´Ù¸é,
    TRANSLATE(arg, a, b)
    °ú °°ÀÌ ¾²¸é µË´Ï´Ù.
    À̶§ arg1Àº Column NameÀ̳ª ¹®ÀÚ¿­À̾î¾ß ÇÕ´Ï´Ù.
    ¿¹¸¦ µé¾î,
    SELECT TRANSLATE ('AABBA', 'B', 'C')
    FROM DUAL;

    ¶ó°í ¾²¸é
    °á°ú´Â AACCA°¡ µÇ°ÚÁÒ.

    REPLACE¸¦ »ç¿ëÇϸé ÇÑ ¹®ÀÚ°¡ ¾Æ´Ï¶ó ¹®ÀÚ¿­·Î ±³Ã¼ÇÒ ¼ö ÀÖ½À´Ï´Ù.
    ¿¹¸¦ µé¾î,
    SELECT REPLACE ('JACK and JUE', 'J', 'BL')
    FROM DUAL;

    ¶ó°í ¾²¸é
    °á°ú´Â BLACK and BLUE°¡ µÇ°ÚÁÒ.


¾î·Á¿î °ÍÀº ¾ø¾úÀ» °ÍÀÔ´Ï´Ù.
¾ÕÀ¸·Î 10¿©È¸ÀÇ °­Á¸¸ ´õÇÏ¸é ±âÃÊ °úÁ¤ÀÌ ³¡³³´Ï´Ù.

µ¿ÁÖ ÀÚ´Â ¸ð½ÀÀÌ ³Ê¹« ±Í¿±³×¿ä.
ÀÌ»ó µ¿Á־ƺü ¼Õº´¸ñÀ̾ú½À´Ï´Ù.

Prev
   ¿À¶óŬ µ¥ÀÌÅÍ °Ë»ö - Scalar Function(3) º¯È¯Çü ÇÔ¼ö ¿Ü

¼Õº´¸ñ
Next
   ¿À¶óŬ µ¥ÀÌÅÍ °Ë»ö - Scalar Function(1) ¼ýÀÚÇü ÇÔ¼ö

¼Õº´¸ñ


Copyright 1999-2024 Zeroboard / skin by Zetyx