숫자함수
--abs : 절대값
--ceil : 올림
--floor : 내림
--round : 반올림
--round(숫자,자릿수) : 숫자의 소수점 이하 몇번째 자릿수에서 반올림
--round(숫자,-자릿수) : 숫자의 뒤 몇번째 자릿수에서 반올림
--power(숫자1,숫자2) : 숫자1의 숫자2승
(예제)
select abs(-5), abs(5) from dual; --절대값
select ceil(2.7), ceil(2.1) from dual; --무조건 올림
select floor(2.7), floor(2.1) from dual; --무조건 내림
select round(2.7), round(2.1) from dual; --반올림
select round(123.456,2) from dual; --소수점이하 2자리 반올림
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
문자열 처리함수
--concat : 문자열 더하기
--initcap : 앞글자만 대문자 출력
--lower: 앞글자만 소문자 출력
--upper : 모든글자 대문자 출력
select concat('Oracle','Java')name from dual; --문자열 더하기
select initcap('happy'),lower('Happy'),upper('Happy') from dual;
--lpad : 문자열 3500을 10글자로 츨력하는데 남는 왼쪽자리는 *로 채움
select lpad('3500',10,'*') from dual;
select lpad('3500',10) from dual; --뒤에 생략하면 공백으로 출력됨
--substr
select substr('happyday',3,3) from dual; --3번열부터 3번째까지만 출력(첫번째 인덱스1)
select substr('happyday',3) from dual; --3번열부터 끝까지 출력
select length('happyday') from dual; --happyday의 문자개수 출력
select replace('HappyDay','Day','Home') from dual;
--trim : 앞뒤 공백제거
select trim(' Happy ') ||'*' from dual; --|| 연결연산자
--날짜함수
select to_char(sysdate,'yyyy-mm-dd hh24:mi') from dual;
--화폐
select to_char(3458952,'L999,999,999')from dual; --L은 화폐단위
selec to_date('2020/01/01','yyyy-mm-dd')from dual; --문자열 형태의 날짜를 date타입으로 변환
'Oracle' 카테고리의 다른 글
210901_join (0) | 2021.09.01 |
---|---|
210901_오류 (0) | 2021.09.01 |
210901_rollup,cube (0) | 2021.09.01 |
210831_update,delete (0) | 2021.08.31 |
210831_서브쿼리 (0) | 2021.08.31 |