TECH
QUESTION
자주하는 질문답변 입니다.
Oracle
작성자 | 유건데이타 | 등록일 | 2015-05-16 |
제목 | AUTOTRACE IN SQL*PLUS 3.3 | ||
---|---|---|---|
NEW FEATURE:AUTOTRACE IN SQL*PLUS 3.3
====================================== Autotrace는 SQL*Plus 3.3부터 지원하는 New feature로서 기존에는 init.ora에 SQL_TRACE=TRUE를 setting 후 얻어진 trace file을 TKPROF란 utility를 이용하여 SQL 문의 수행 경로, 각종 통계 정보를 얻었다. 그러나, SQL*Plus 3.3부터는 이것을 간단히 처리할 수 있는 방법을 제공한다. 1. SQL*Plus를 실행하여 scott user로 접속한 후, plan table을 생성한다. #sqlplus scott/tiger SQL>@$ORACLE_HOME/rdbms/admin/utlxplan 2. 다음에 sys user에서 PLUSTRACE란 ROLE을 만든다. SVRMGR>connect internal; SVRMGR>create role plustrace; SVRMGR>grant select on v_$sesstat to plustrace; SVRMGR>grant select on v_$statname to plustrace; SVRMGR>grant select on v_$session to plustrace; SVRMGR>grant plustrace to dba with admin option; SVRMGR>grant plustrace to scott; 비고) 위의 grant 문은 client에 SQL*Plus 3.3이 install되어 있는 경우 C:ORAWIN95\PLUS33\PLUSTRCE.SQL이라는 script에 기록되어 있다. 다음과 같이 실행해 주면 된다. 1> connect sys/manager 2> @$ORACLE_HOME/sqlplus/admin/plustrce.sql 3> grant plustrace to scott; 3. 다음에는 scott user로 connect하여 작업한다. #sqlplus scott/tiger SQL>set autotrace on SQL>select * from emp; Execution Plan ----------------------------------------------- 0 SELECT STATEMENT Optimizer=CHOOSE 1 0 TABLE ACCESS (FULL) OF 'EMP' Statistics ----------------------------------------------- 389 recursive calls 5 db block gets 53 consistent gets 12 physical reads 0 redo size 1049 bytes sent via SQL*Net to client 239 bytes received via SQL*Net from client 4 SQL*Net round-trips to/from client 0 sorts (memory) 0 sorts (disk) 13 rows processed 4. 참고로 set autotrace에는 여러가지 option을 부여해 작업할 수도 있다. 예)set autotrace on => Explain plan and statistics. set autotrace on explain => Explain plan only. set autotrace traceonly => select된 결과는 빼고 trace만 display 시킴. set autotrace on statistics=> sql statement execution statistics. 5. 서버 버젼과 상관없다. Server가 7.2 version 이하일지라도 clinet에 SQL*Plus 3.3이 install되어 있으면 client에서 sqlplus 3.3을 구동시켜 server에 접속하여 위와 같이 작업하면 무리없이 작업이 가능하다. Reference Documents ------------------- |
Comment | |||
---|---|---|---|
등록된 코멘트가 없습니다. |