★ 단일행 함수의 종류 ★
- 문자 함수
- 숫자 함수
- 날짜 함수
- 변환 함수
- 기타 함수
mod(숫자1, 숫자2)
숫자1을 숫자2로 나누었을 때의 나머지를 나타낸다.
round(숫자1, 숫자2)
숫자1을 숫자2에 따라 반올림해준다.
trunc(숫자1, 숫자2)
숫자1을 숫자2에 따라 절삭해준다.
-> 반올림 X, 무조건 짜르기
select 5/2, mod(5,2)
, round(987.65,1), round(987.65,0), round(987.65,-1)
, trunc(987.65,1), trunc(987.65,0), trunc(987.65,-1)
from dual;
-- 결과
-- 5/2 = 2.5(sql) | 5/2 = 2(java)
-- mod(5/2) = 1 -- 5/2 의 나머지
/*
숫자2의 값에 따른 변동
- 1 일 경우 소수 첫째자리까지 나타낸다.
- 0 일 경우 정수 1자리까지 나타낸다.
- -1 일 경우 정수 10자리까지만 나타낸다.
*/
-- round(987.65,1), round(987.65,0), round(987.65,-1)
-- 987.7 | 988 | 990
-- 5부터 올림
-- trunc(987.65,1), trunc(987.65,0), trunc(987.65,-1)
-- 987.6 | 987 | 980
power(숫자1, 숫자2)
숫자1을 숫자2만큼 거듭제곱
sqrt(숫자)
숫자의 제곱근
sin(숫자), cos(숫자), tan(숫자), asin(숫자), acos(숫자), atan(숫자)
직각삼각형인 경우 -> 밑변 a, 높이 b, 빗변 c
▷ 삼각함수
-> sin = b/c , cos = a/c , tan b/a
->원의 각도 구하기 : cos θ = a/c
▷ 역삼각함수
-> asin, acos, atan 를 통해 각도 알아보기
-> 원의 각도 구하기
asinθ = c/sin, acosθ = cos/c, atanθ = sin/cos
log(10,100) = 2 -- 10^2 이 100 이기 때문이다.
select ceil(1.1), ceil(1), ceil(-1.1)
, floor(1.1), floor(1), floor(-1.1)
from dual;
-- 결과
-- ceil(1.1), ceil(1), ceil(-1.1)
-- 2 | 1 | -1
-- floor(1.1), floor(1), floor(-1.1)
-- 1 | 1 | -2
-- ceil => up(무조건 올림 정수까지)
-- floor => down(무조건 내림 정수까지)
ascii('문자')
문자 -> char 타입 숫자
chr(숫자)
숫자 -> ascii 타입
Ascii | A | a | 0 | ' ' (공백) Char | 65 | 97 | 48 | 32
-> local_hr에서작업한것