환합니다. 단순히 분석이 목적인 코드를 작성한다면 이 변환 과정을 자세히 이해할 필요는 없
습니다. 하지만 데이터베이스가 연산을 실행하는 순서를 잘 안다면
SQL
을 활용한 업무를 수행
할 때 매우 도움이 되며, 예상과 다른 결과가 나왔을 때 이를 디버깅하는 데도 유용합니다.
NOTE
_ 최신 데이터베이스에는 쿼리를 가장 효율적인 방법으로 실행하기 위한 정교한 쿼리 최적화 기능이
있습니다. 쿼리 최적화 기능으로 각 구문을 다양한 순서로 조합하며 확인해보기 때문에 사람이 직접 쿼리를
최적화할 필요는 없습니다. 다만, 복잡한 쿼리에 사용되는 서브쿼리 등의 중간 결과까지 다양한 순서로 확인
해보지는 않습니다.
일반적인 쿼리 실행 순서는 [표
8
-
1
]과 같습니다. 사용한 절의 우선순위에 따라 실행됩니다.
표
8-1
SQL
쿼리 실행 순서
순서
SQL
절
1
FROM
(
JOIN
및
ON
절 포함)
2
WHERE
3
GROUP
BY
(집계 포함)
4
HAVING
5
윈도우 함수
6
SELECT
7
DISTINCT
8
UNION
9
ORDER
BY
10
LIMIT
과
OFFSET
데이터베이스는 우선
FROM
절의 테이블을 실행합니다. 이때, 이 테이블과 연관된 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.
O’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
I wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
I’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
I'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.