Oracle연산자

유기욱·2022년 5월 26일

연산자

  • 산술 연산자( + - / * )

  • 비교 연산자( = <>(같지 않다) !=(같지않다) >= <= )
    숫자 뿐만 아니라 문자나 날짜 값을 비교하는 것도 가능
    예) 'A' < 'C'
    '2020-10-10' < '2022-05-17'

  • 논리 연산자( and, or, not )

  • 집합 연산자( union, union all, minus, intersect )
    union >> 두 조건에 합하는 데이터를 출력 (~와 ~) 합집합
    select employee_id, first_name, department_id from EMPLOYEES where department_id = 60
    union
    select employee_id, first_name, department_id from EMPLOYEES where department_id = 100;

minus >> 두 조건에 합하는 데이터를 제외하고 출력 (~에서 ~까지를 제외하고) 차집합
select employee_id, first_name, department_id from EMPLOYEES where department_id <=100
minus
select employee_id, first_name, department_id from EMPLOYEES where department_id >=50;

intersect >> 두 조건에 합하는 데이터를 출력 (~에서 ~까지) 교집합
select employee_id, first_name, department_id from EMPLOYEES where department_id <=100
intersect
select employee_id, first_name, department_id from EMPLOYEES where department_id >=50;

  • SQL 연산자( between, in, like, is null ) not이 붙으면 반대의미
    between A and B>> 두 값의 범위에 해당하는 데이터만 출력할 때 사용되는 확장 연산자
    select * from EMPLOYEES where EMPLOYEE_ID BETWEEN 120 and 130;

(not) in 연산자 >> ( ) 안에 입력된 문자에 해당하는 데이터만 출력
select * from EMPLOYEES where FIRST_NAME in('Steven', 'John', 'Peter', 'Payam');

is (not) null >> 데이터가 null 값인 데이터만 출력
select * from EMPLOYEES where COMMISSION_PCT is null;

(not) like 연산자 >> 문자열 속성에서 부분적으로 일치하는 데이터만 출력 할 때 사용
-- % > 0개 이상의 문자(문자의 내용과 갯수는 상관 없음)
-- > 1개의 문자
-- Like 'data%' >> data로 시작하는 문자열
select from LOCATIONS where CITY like 'South%';
-- Like '%data' >> data로 끝나는 문자열
select
from LOCATIONS where STREET_ADDRESS like '%St';
-- Like '%data%' >> data가 포함 된 문자열
-- Like 'data____'(
4개) >> data로 시작하는 8개 문자열
select * from LOCATIONS where city like 'South__';
-- Like '__
data'( _ 4개) >> data로 끝나는 8개 문자열

0개의 댓글