쉘을 이용하여 sql 문 반복수행하기
출처: https://www.postgresdba.com/bbs/board.php?bo_table=B12&wr_id=50
ㅁ oracle
[/ora11g/dba/oradba]cat loop.sh
#!/usr/bin/ksh
SLEEP_SEC=1
LOOP_MAX=3
COUNT=0
while [ $COUNT -lt $LOOP_MAX ]
do
echo "@$1"
sleep $SLEEP_SEC
COUNT=`expr $COUNT + 1`
done
MSSTDB1:[/ora11g/dba/oradba]cat loop.sql
INSERT INTO dbadm.T_0814 SELECT
SYSDATE SAMPLE_TIME, INST_ID, MACHINE,
COUNT(*) TOTAL_CNT,
SUM(CASE WHEN STATUS='ACTIVE' THEN 1 ELSE 0 END) ACTIVE_CNT,
SUM(CASE WHEN STATUS='ACTIVE' THEN 0 ELSE 1 END) INACTIVE_CNT
FROM GV$SESSION WHERE machine in ('MSFRWS1','MSFRWS2',
'MSWAS01',
'MSWAS02') AND
SYSDATE BETWEEN TO_DATE('20150814 080000','YYYYMMDD HH24MISS') AND TO_DATE('20150817 110000','YYYYMMDD HH24MISS')
AND
TO_CHAR(sysdate,'HH24:MI:SS') BETWEEN '09:00:00' AND '11:00:00'
GROUP BY SYSDATE, INST_ID, MACHINE;
commit;
MSSTDB1:[/ora11g/dba/oradba]./loop.sh loop.sql | sqlplus -s oradba/xxxx
'정보관리(데이터베이스, DB) > 오라클' 카테고리의 다른 글
Oracle XE 18c 샘플데이터 HR 스키마 생성 과정 (0) | 2023.07.26 |
---|---|
오라클 18c C## 붙이는 이유 (0) | 2023.07.26 |
리눅스 Rock9 오라클18c 설치하기 (0) | 2023.07.26 |
오라클 SGA (0) | 2023.06.22 |
오라클_자주 쓰는 SQL 문 (0) | 2022.12.05 |