DBMS study 01

유요한·2022년 4월 26일
0

DBMS

목록 보기
7/8

Any

● 서브쿼리의 여러개의 결과 중 한 가지만 만족해도 가능
● some은 any와 동일한 의미로 사용
● =any 구문은 in과 동일한 의미
	select * form city
    where population > any ( select population from city 
    						where district = "New York");
	select * form city
    where population > some ( select population from city 
    						where district = "New York");
→ any가 없으면 서브쿼리에서 값이 여러개가 나와서 에러가 생기는데
  any를 사용함으로써 사용가능해진다.
  

all

● 서브쿼리의 여러 개의 결과를 모두 만족 시켜야 함
	select * form city
    where population > all ( select population from city 
    						where district = "New York");
→ New York에 인구수보다 많은 인구수의 도시를 보여줘라는 의미

distinct

● 중복된 것은 1개씩만 보여주면서 출력(중복제거)
● 테이블의 크기가 클수록 효율적
	select distinct countrycode from city;

limit

● 출력 개수를 제한
● 상위의 N개만 출력하는 'limit N'구문
● 서버의 처리량을 많이 사용해 서버의 전반적인 성능을 나쁘게 하는 악성 쿼리문
  개선할 때 사용
  

rollup

● 총합 또는 중간합계가 필요할 경우 사용
● group by절과 함께 with rollup문 사용

	select countrycode, name, sum(population) from city 
    group by countrycode, name with rollup;

→ null 옆에 써있는 숫자는 위에 있는 것들을 합친 결과값이다.
→ 예를들어, countrycode가 AFG인 null옆에 2332100이란 숫자는
  Herat, Kabul, Mazar-e-Sharif, Qandahar을 합친 숫자이다.
profile
최선을 다하자!!

0개의 댓글