SQL 실행 계획 확인 방법 (SQL Plus 의 Autotrace 기능)

 

SQL*PLUS Autotrace 기능 활성화

- PLUSTRACE 권한 생성

SQL>conn / as sysdba

SQL>@?/sqlplus/admin/plustrce.sql (오타아님)

 

- 해당 사용자에게 PLUSTRACE 권한 부여

SQL>grant PLUSTRACE to scott;

 

- 해당 사용자로 로그인 후 PLAN Table 생성

SQL>conn scott/tiger

SQL>@?/rdbms/admin/utlxplan.sql

 

Autotrace 모드 설정

 

SQL>set autotrace on

SQL>set autotrace off

SQL>set autotrace traceonly

SQL>set autotrace traceonly explatin

SQL>set autotrace traceonly statistics

 

SQL*plus Autotrace 실습

- 100000 개의 Record 가 들어있는 Table 에서 name 컬럼에 abc 가 들어있는 Row 를 질의하는 SQL 의 실행계획 만들기.

SQL> set autotrace on

SQL> select * from scott.tt920

2 where name LIKE '%abc%';

- 위의 실행 계획을 보면 Operation 컬럼에 Row 를 보면 위쪽과 아래쪽을 비교하여 오른쪽으로 밀린 것을 먼저 수행, 즉 id=1 부터 수행 후 id=0 을 수행한다는 뜻 입니다.

- index 가 있을경우 더 다양한 실행계획이 나올 수 있습니다.

 

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Users\Yeon>sqlplus sys/oracle@TAF as sysdba

SQL*Plus: Release 10.2.0.4.0 - Production on Wed Aug 10 02:58:32 2011

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.

ERROR:
ORA-12170: TNS:Connect timeout occurred


Enter user-name:
ERROR:
ORA-12560: TNS:protocol adapter error


Enter user-name:
ERROR:
ORA-12560: TNS:protocol adapter error


SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus

============================================================================================================
원인 - sqlnet.ora 파일 설정이 잘 못 되있을 경우
         --> ex)
                    SQLNET.AUTHENTICATION_SERVICES=( NTS)

                    NAMES.DIRECTORY_PATH=(TNSNAMES, EZCONNECT)  ->자세히 보면 공백이 존재한다.
         --> 어처구니 없지만 이러한 이유로도 접속이 안될 수도 있다

해결 -
                    SQLNET.AUTHENTICATION_SERVICES=(NTS)

                    NAMES.DIRECTORY_PATH=(TNSNAMES,EZCONNECT)

+ Recent posts