CONCAT(char1, char2), ||(pipeline)
SELECT CONCAT('문자열1','문자열2') FROM 테이블;
SELECT CONCAT('Hello','bye'), CONCAT('good','bad') FROM DUAL;
CONCAT('HELLO','BYE') | CONCAT('GOOD','BAD') |
---|
Hellobye | goodbad |
SELECT CONCAT('good','bad') CONCATS, 'good' || 'bad' OPERATORS FROM DUAL;
CONCATS | OPERATORS |
---|
goodbad | goodbad |
INITCAP()
- 첫 문자를 대문자로 변환
- 단어와 단어간 공백 및 구분자 '/' 기준
SELECT INITCAP('문자열') FROM 테이블;
SELECT INITCAP('good morning') FROM DUAL;
INITCAP('GOODMORNING') |
---|
Good Morning |
SELECT INITCAP('good/bad morning') FROM DUAL;
INITCAP('GOOD/BADMORNING') |
---|
Good/Bad Morning |
LOWER(), UPPER()
SELECT LOWER('문자열') FROM 테이블;
<- 소문자 변환
SELECT UPPER('문자열') FROM 테이블;
<- 대문자 변환
SELECT LOWER('GOOD'), UPPER('good') FROM DUAL;
LOWER('GOOD') | UPPER('GOOD) |
---|
good | GOOD |
LPAD(expr1, n [,expr2])
SELECT LPAD('문자열1', n, '문자열2') FROM 테이블;
SELECT LPAD('good', 6) FROM DUAL;
SELECT LPAD('good', 6) "LPAD1",
LPAD('good', 6, '@') "LPAD2",
LPAD('good', 8, 'L') "LPAD3"
FROM DUAL;
LPAD1 | LPAD2 | LPAD3 |
---|
good | @@good | LLLLgood |
RPAD(expr1, n [,expr2])
SELECT RPAD('문자열1', n, '문자열2') FROM 테이블;
SELECT RPAD('good', 6) "RPAD1",
RPAD('good', 6, '@') "RPAD2",
RPAD**('good', 8, 'L') "RPAD3"
FROM DUAL;
RPAD1 | RPAD2 | RPAD3 |
---|
good | good@@ | goodLLLL |
LTRIM(char[,set])
- char에서 set으로 지정된 문자를왼쪽에서 제거
SELECT LTRIM('문자열','문자') FROM 테이블;
SELECT LTRIM('goodbye','g'),
LTRIM('goodbye','o'),
LTRIM('goodbye','go')
FROM DUAL;
LTRIM('GOODBYE','G') | LTRIM('GOODBYE','O') | LTRIM('GOODBYE','GO') |
---|
oodbye | goodbye | dbye |
RTRIM(char[,set])
- char에서 set으로 지정된 문자를오른쪽에서 제거
SELECT RTRIM('문자열','문자') FROM 테이블;
SELECT RTRIM('goodbye','g') FROM DUAL;
RTRIM('GOODBYE','E') |
---|
goodby |
SUBSTR()
SELECT SUBSTR('문자열', 인텍스) FROM 테이블
SELECT SUBSTR('good morning john', 8, 4) FROM DUAL;
SUBSTR('GOODMORNINGJOHN', 8, 4) |
---|
rnin |
SELECT SUBSTR ('good morning john', 8) FROM DUAL;
SUBSTR('GOODMORINGJOHN', 8) |
---|
rning john |
SELECT SUBSTR('good morning john', -4, 2) FROM DUAL;
SUBSTR('GOODMORNINGJOHN', -4, 2) |
---|
jo |
SELECT SUBSTR ('good morning john', -4, 0) FROM DUAL;
SUBSTR('GOODMORNINGJOHN, -4, 0) |
---|
(null) |
SUBSTRB()
SELECT SUBSTRB('문자열', n Byte) FROM 테이블;
SUBSTRB('GOODMORNINGJOHN', 8, 4 ) |
---|
rnin |
REPLACE()
SELECT REPLACE('문자열', '원 문자열', '바꿀 문자열') FROM DUAL;
SELECT REPLACE('good morning tom', 'morning', 'evening') FROM DUAL;
REPLACE('GODMORNINGTOM','MORNING','EVENING') |
---|
good evening tom |
TRANSLATE(expr, frm_str, to_str)
SELECT REPLACE('You are not alone', 'You', 'We'),
TRANSLATE('You are not alone', 'You', 'We')
FROM DUAL;
REPLACE('YOUARENOTALONE','YOU','WE') | TRANSLATE('YOUARENOTALONE','YOU','WE') |
---|
We are not alone | We are net alene |
- replace, translate 차이
replace
: 'AbC', 'BbC' -> 'BbC'
translate
: 'AbC', 'BcD' -> 'Bc~D~' // 1:1 대응
TRIM([LEDING, TRAILING, BOTH] [, trim_chr][FROM] trim_src)
- trim_src에서 trim_chr를 앞, 뒤 혹은 모두에서 제거한 결과 반환
LENGTH()
SELECT TRIM([LEADING] [,'문자'] [FROM ]'문자열') FROM DUAL;
SELECT TRIM([TRAILING] [,'문자'] [FROM]'문자열') FROM DUAL;
SELECT TRIM([BOTH\] [,'문자'\] [FROM]'문자열') FROM DUAL;
SELECT LENGTH(TRIM(LEADING FROM 'good')) FROM DUAL;
LENGTH(TRIM(LEADINGFROM('GOOD')) |
---|
4 |
SELECT LENGTH(TRIM(TRAILING FROM 'good')) FROM DUAL;
LENGTH(TRIM(TRAILINGFROM('GOOD')) |
---|
4 |
SELECT LENGTH(TRIM(BOTH FROM 'good')) FROM DUAL;
LENGTH(TRIM(BOTHFROM('GOOD')) |
---|
4 |
SELECT TRIM(TRAILING 'd' FROM 'good') FROM DUAL;
TRIM(TRAILING'D'FROM'GOOD') |
---|
goo |
ASCII()
SELECT ASCII('a') FROM DUAL;
INSTR(string, src_str, pos, occur)
SELECT INSTR('good morning john', 'or', 1) FROM DUAL;
INSTR('GOODMORNINGJOHN','OR',1) |
---|
7 |
Reference