본문 바로가기

춤추는 프로그래머/Database.

[오라클] REPLACE 함수




# REPLACE(char, searh_str, replace_str)

    문자열을 다른문자열로 바꾸는 함수이다.
    char 문자열에서 search_str 을 찾아 replace_str 로 바꾼다.
    replace_str 값이 생략되었을때는 searh_str 문자열을 제거한 결과를 돌려준다.
   
   
    SELECT REPLACE('You are so beautiful.', 'so', 'no') REPLACE_STR FROM DUAL 
    REPLACE_STR         
    ---------------------
    You are no beautiful.
    1 row selected
    
    
    SELECT REPLACE('You are so beautiful.', 'so') REPLACE_STR FROM DUAL
    REPLACE_STR       
    -------------------
    You are  beautiful.
    1 row selected