본문 바로가기
IT/@SQL

Select 문 / 기본 명령어 활용

by He;story 2020. 5. 25.

Oracle 에서 제공해주는 HR 계정으로 활용

Oracle과 SQL Developer 를 설치하면 HR 계정을 활용할 수 있습니다.

https://awesomek.tistory.com/entry/Oracle-11g-release2-%EC%84%A4%EC%B9%98%ED%95%98%EA%B3%A0-%EC%89%BD%EA%B2%8C-%EC%84%A4%EC%A0%95%ED%95%98%EA%B8%B0?category=865508

 

Oracle 11g release2 설치하고 쉽게 설정하기

SQL(Structured Query Language) 는 관계형 데이터베이스 언어로 데이터 삽입, 삭제, 갱신 등을 사용하기 위해서는 Oracle 11g 와 SQL Developer를 설치하여 테스트를 해볼 예정입니다. 1. Oracle 사이트 접속 오..

awesomek.tistory.com


Oracle에서 제공되는 HR 계정에는 아래 테이블을 제공해주고 있습니다.

COUNTRIES / EPARTMENTS/EMPLOYEES/JOB_HISTORY/JOBS/LOCATION/REGIONS


DESC 명령어

Desc employees[테이블];

EMPLOYEES 테이블의 속성값을 확인

 


Select 명령어

Select * from EMPLOYEES[테이블];

EMPLOYEES 테이블의 모든 정보를 확인


DISTINCT 명령어

Select DISTINCT job_id from employees;

EMPLOYEES 테이블에서 job_id 컬럼을 중복 제거하여 출력


Select employee_id, salary from employees where last_name='Smith';

EMPLOYEES 테이블에서 Last_name 이 Smith인 사람을 employee_id와 Salary 출력


Select employee_id as "ID", salary as "연봉" from employees;

EMPLOYEES 테이블에서 EMPLOYEE_ID를 ID로 SALARY 를 연봉으로 출력


Select first_name, last_name, salary from employees where salary >= 5000;

EMPLOYEES 테이블에서 SALARY가 5000 이상인 사람의 First_name, Last_name, Salary 출력


Select first_name, last_name, hire_date from employees where hire_date >='04/01/01';

EMPLOYEES 테이블 중 Hire 고용날짜가 04년 1월 1일 이후에 들어온 사람의 first_name, Last_name, Hire_date 출력


Select first_name, last_name, job_id, department_id
from employees
where department_id = 50 and job_id ='SH_CLERK'; 

 

EMPLOYEES 테이블 중 Department 가 50이고 job_id 가 SH_CLERK 사람의

First_name, Last_name, job_id, department_id 출력

 


Select first_name, last_name, department_id from employees
where not (department_id = 50);

EMPLOYEES 테이블에서 department_id 가 50이 아닌 사람의 first_name, last_name, department_id 출력

 


Select first_name, last_name, department_id, manager_id from employees 

where department_id = 50 or manager_id = 100;

 

EMPLOYEES 테이블에서 department_id 가 50 또는 manager_id 가 100인 사람의 first_name, Last_name, department_id, manager_id 출력


Select first_name, last_name, salary from employees 
where salary >= 4000 and salary <=8000;

 

Select first_name, last_name, salary from employees 
where salary between 4000 and 8000;

 

봉급이 4000 이상 8000 이하의 사람의 first_name, last_name, salary 출력


Select first_name, last_name, salary from employees 
where salary in (6500, 7700, 13000);

 

연봉이 6500, 7700, 13000 인 사람의 First_name, Last_name, Salary 출력


Select first_name, last_name from employees
where first_name like '%d';

 

first_name 이 d로 끝나는 사람의 first_name, last_name 출력

 

댓글