posted by 구름너머 2013. 4. 4. 10:30

SELECT LTRIM('xyxXxyLAST WORD','xy') "LTRIM example"
   FROM DUAL;

LTRIM example
------------
XxyLAST WORD

 

xy패턴의 문자열을 차례로 왼쪽부터 찾아서 하나씩 지우게 되므로

첫번째 문자 x를 지우고 다음 y를 지우고 그 다음 x를 지우고 그 다음 y를 찾았으나

없으므로 그대로 리턴한다.  얼핏보면 'xXxyLAST WORD' 이 될듯 하지만 처리방식이 문자 하나씩 찾는 방식이다.

다음예를 보자...

SELECT LTRIM('abcabcabkabcABxcXabAbabAAbb','abc') as aa
from dual

AA
kabcABxcXabAbabAAbb 

 

 

LTRIM

Syntax

ltrim::=

Text description of functions164.gif follows
Text description of ltrim


Purpose

LTRIM removes characters from the left of char, with all the leftmost characters that appear in set removed; set defaults to a single blank. If char is a character literal, then you must enclose it in single quotes. Oracle begins scanning char from its first character and removes all characters that appear in set until reaching a character not in set and then returns the result.

Both char and set can be any of the datatypes CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB, or NCLOB. The string returned is of VARCHAR2 datatype and is in the same character set as char.

Examples

The following example trims all of the left-most x's and y's from a string:

SELECT LTRIM('xyxXxyLAST WORD','xy') "LTRIM example"
   FROM DUAL;

LTRIM example
------------
XxyLAST WORD

'ORACLE' 카테고리의 다른 글

rawtohex 와 chr 사용  (0) 2013.12.20
connect by [Oracle 9i 에서 10g CONNECT_BY_ROOT 써먹기]  (0) 2013.04.04
28일 수업  (0) 2013.03.28
MATERIALIZED VIEW 생성  (0) 2013.03.28
trace and mview  (0) 2013.03.28