Áö³ ½Ã°£À» ÅëÇØ ´À³¢¼ÌµíÀÌ Scalar ÇÔ¼ö´Â ±×¸® ¾î·ÆÁö ¾Ê½À´Ï´Ù.
ÇÔ¼ö À̸§¸¸À¸·Îµµ ±× ¶æÀÌ ÁüÀÛÀÌ µÇ°í »ç¿ë¹ýµµ ±×¸® º¹ÀâÇÏÁö ¾Ê½À´Ï´Ù.
¿À´ÃÀº Áö³ ½Ã°£¿¡ ÀÌ¾î ¹®ÀÚÇü ÇÔ¼ö¿¡ ´ëÇØ ±× Á¾·ù¸¦ °£·«ÇÏ°Ô ¾Ë¾Æº¸°í °£´ÜÇÑ ½Ç½ÀÀ» Çغ¸µµ·Ï ÇÏ°Ú½À´Ï´Ù.
- ¹®ÀÚÇü ÇÔ¼öÀÇ Á¾·ù
- UPPER, LOWER, INITCAP ÇÔ¼ö
¹é¹®ÀÌ ºÒ¿©ÀÏŸ, ÀÏ´Ü ÀÔ·ÂÇØ º¸°í ±× °á°ú¸¦ º¾½Ã´Ù.
SQL*Plus¸¦ ½ÇÇàÇؼ ´ÙÀ½ ¹®ÀåÀ» Á÷Á¢ ÀÔ·ÂÇØ º¸¼¼¿ä.
SELECT EMP_NUM,
LOWER(LAST_NAME),
INITCAP(FIRST_NAME),
UPPER(ADDRESS)
FROM EMP;
- CONCAT ÇÔ¼ö
¹®ÀÚ¿ ÇÕ¼º ÇÔ¼ö¶ó°í ÇßÁÒ?
Á÷Á¢ Çѹø Çغ¸¼¼¿ä.
SELECT CONCAT( LAST_NAME, FIRST_NAME )
FROM EMP;
¼º°ú À̸§ÀÌ ¸ðµÎ ºÙ¾î¼ Ãâ·ÂµË´Ï´Ù.
±×·³ ÀÌ·¸°Ô Çغ¸¸é ¾î¶³±î¿ä?
SELECT CONCAT(FIRST_NAME, '´Ô' )
FROM EMP;
Á÷Á¢ ±× °á°ú¸¦ È®ÀÎÇØ º¸¼¼¿ä.
- 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ÇßÀ» ¶§¿Í ºñ±³ÇØ º¸¼¼¿ä.
- LENGTH ÇÔ¼ö
ƯÁ¤ Ä÷³ÀÇ ±æÀ̸¦ ±¸Çϱâ À§ÇÑ ÇÔ¼öÀε¥, Çѱ۰ú ¿µ¹® ¸ðµÎ 1¹ÙÀÌÆ®·Î Ãë±ÞÇÕ´Ï´Ù.
µ¥ÀÌÅÍÀÇ À¯Çüº°·Î LENGTH ÇÔ¼ö¸¦ Àû¿ëÇßÀ» ¶§ ±¸ÇÒ ¼ö ÀÖ´Â ±æÀÌ°¡ Á¶±Ý ´Ù¸¥µ¥,
NUMBERÇü µ¥ÀÌÅͶó¸é ½ÇÁ¦ ±æÀ̸¦ ±¸ÇÏ°í
DATEÇü µ¥ÀÌÅͶó¸é Default Date FormatÀÇ ±æÀ̸¦ ±¸ÇÕ´Ï´Ù.
CHARÇüÀ̶ó¸é Á¤ÀÇµÈ ±æÀ̸¦ ±¸ÇÏ°í
VARCHAR2ÇüÀ̶ó¸é Á¤ÀÇµÈ ±æÀÌ¿Í »ó°ü¾øÀÌ ½ÇÁ¦ ±æÀ̸¦ ±¸ÇÕ´Ï´Ù.
LONG Çüµµ ½ÇÁ¦ ±æÀ̸¦ ±¸ÇÕ´Ï´Ù.
ÀÚ, ½Ç½ÀÇØ º¼±î¿ä?
SELECT LENGTH(EMP_NUM),
LENGTH(ADDRESS)
FROM EMP;
- 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;
¿ä°Ç Á÷Á¢ Çѹø Çغ¸¼¼¿ä.
- 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°¡ µÇ°ÚÁÒ?
- 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¿©È¸ÀÇ °Á¸¸ ´õÇÏ¸é ±âÃÊ °úÁ¤ÀÌ ³¡³³´Ï´Ù.
µ¿ÁÖ ÀÚ´Â ¸ð½ÀÀÌ ³Ê¹« ±Í¿±³×¿ä.
ÀÌ»ó µ¿Á־ƺü ¼Õº´¸ñÀ̾ú½À´Ï´Ù.
|