메뉴 여닫기
개인 메뉴 토글
로그인하지 않음
만약 지금 편집한다면 당신의 IP 주소가 공개될 수 있습니다.
(새 문서: == 임시 테이블 (Temporary Tables) == <source lang=sql> -- 세션 동안만 유지되는 임시 테이블 생성 (SQL Server 예제) CREATE TEMPORARY TABLE #temp_top_customers ( customer_id INT, total_spent DECIMAL(10,2) ); -- 임시 테이블에 데이터 삽입 INSERT INTO #temp_top_customers SELECT customer_id, SUM(amount) FROM orders GROUP BY customer_id HAVING SUM(amount) > 10000; -- 임시 테이블 조회 SELECT * FROM #temp_top_customers ORDER BY total_spe...)
 
 
18번째 줄: 18번째 줄:
SELECT * FROM #temp_top_customers ORDER BY total_spent DESC;
SELECT * FROM #temp_top_customers ORDER BY total_spent DESC;
</source>
</source>
**설명**:
{{설명
- 세션이나 트랜잭션 동안만 존재하는 임시 테이블
|제목=''' 설명 '''
- 중간 결과 저장이나 복잡한 쿼리 분해 시 유용
# 세션이나 트랜잭션 동안만 존재하는 임시 테이블
- 데이터베이스 종류에 따라 생성 문법이 다름(#, TEMPORARY, GLOBAL TEMPORARY 등)
# 중간 결과 저장이나 복잡한 쿼리 분해 시 유용
# 데이터베이스 종류에 따라 생성 문법이 다름(#, TEMPORARY, GLOBAL TEMPORARY 등)
}}

2025년 7월 2일 (수) 20:37 기준 최신판

임시 테이블 (Temporary Tables)

-- 세션 동안만 유지되는 임시 테이블 생성 (SQL Server 예제)
CREATE TEMPORARY TABLE #temp_top_customers (
    customer_id INT,
    total_spent DECIMAL(10,2)
);

-- 임시 테이블에 데이터 삽입
INSERT INTO #temp_top_customers
SELECT customer_id, SUM(amount)
FROM orders
GROUP BY customer_id
HAVING SUM(amount) > 10000;

-- 임시 테이블 조회
SELECT * FROM #temp_top_customers ORDER BY total_spent DESC;
blur_on 설명
  1. 세션이나 트랜잭션 동안만 존재하는 임시 테이블
  2. 중간 결과 저장이나 복잡한 쿼리 분해 시 유용
  3. 데이터베이스 종류에 따라 생성 문법이 다름(#, TEMPORARY, GLOBAL TEMPORARY 등)