-
[SQL] bind 변수Database 2023. 11. 21. 23:11
- sql 구문 중 where절에 column과 비교되는 값이 바인드 변수 형태로 사용하는 경우의 변수
- 바인드 변수의 자리에는 parameter로 넘겨지는 값들이 대체됨
- Hard Parse를 줄이기 위해 사용

#예제
create table t1 (c1 number); #bind 변수 사용 X insert into t1 values (1); select * from t1; C1 ---------- 1 #bind 변수 사용 O var a number; exec :a := 2; insert into t1 values (:a); select * from t1; C1 ---------- 1 2 select * from t1 where c1 like :a; C1 ---------- 2정의 3가지
#1 var v1 number; exec :v1 := 1; select * from t1 where c1 in (:v1); C1 ---------- 1 #2 define v2 = 2; select * from t1 where c1 in (&v2); old 1: select * from t1 where c1 in (&v2) new 1: select * from t1 where c1 in (2) C1 ---------- 2 #3 variable v3 number; execute :v3 := 1; select * from t1 where c1 in (:v3); C1 ---------- 1'Database' 카테고리의 다른 글
[SQL] 형 변환 함수 (0) 2023.11.27 [SQL] 예약어(keyword) 조회 (1) 2023.11.27 [SQL] where 절 연산자 (0) 2023.07.13 [SQL] 롤포워드/롤백 (0) 2023.07.09 [SQL] 오라클 출력 포멧 맞추기 (0) 2023.07.09