Sqlplus configuration and session SQL tracking [plain] When sqlplus is started, the two files login. SQL and glogin. SQL will be searched and loaded. The glogin. SQL file is stored in the $ ORACLE_HOME/sqlplus/admin directory by default, and login. SQL can be set in SQLPATH. 1. the login. SQL file login. SQL file can store any commands that can be used in sqlplus, including sqlplus commands and SQL statements. When sqlplus is started, it first looks for the login. SQL file in the current directory, and then finds it in the SQLPATH directory. If you find the login. SQL file, execute all the content in login. SQL before SQLPLUS displays "SQL>. If the login. SQL file is not found, stop searching. Therefore, you can place your favorite common settings in the login. SQL file, which is automatically loaded each time sqlplus is started. Set SQLPATH to add the SQLPATH environment variable to the ORACLE user profile file. Mine is. bash_profile For example: export SQLPATH =/data/app/sqlpath (this path is your login. of course, you can also start sqlplus and then execute the file (use the @ command ). 2. The glogin. SQL file glogin. SQL is a default SQLPLUS setting created by ORACLE for All database users. It is stored in the $ ORACLE_HOME/sqlplus/admin directory by default. When sqlplus is started, all content of the file is automatically executed before "SQL>" is displayed. You can also put some common settings in this file. Code: [SQL] define_editor = vi ---- set the Default Editor set timing on -- display the execution time set serveroutput on size 1000000 -- set the output display, when the buffer is set to 1000000 set trimspool on -- output text offline, spaces at both ends of the text line are removed and the row width is not fixed. if it is off, the line width is equal to linesize set long 5000 -- set the default number of bytes displayed for the LONG and CLOB types set linesize 1000 -- set the text line width to 1000 set pagesize 9999 -- set the page size of SQLPLUS set NULL <null> -- set NULL to display as null column plan_plus_exp format a80 -- set the default width of column globa output in the explain plan obtained by autotrace L_name new_value gname set termout off define gname = idle column global_name new_value gname select lower (user) | '@' | substr (global_name, 1, decode (dot, 0, length (global_name), dot-1) global_name from (select global_name, instr (global_name ,'. ') dot from global_name); set sqlprompt' & gname> 'set termout on -- replace SQL with the current username @ Instance name> display SQL Tracing Method in session: set autotrace off; autotrace report set autotrac is not generated by default. E on explain only displays the optimizer execution path set autotrace on statistics and only displays the SQL statement execution statistics set autotrace on. It displays the optimizer path and SQL statement execution statistics. As follows: [SQL] test @ ORCL> set autotrace on; test @ ORCL> select * from t; ID NAME ---------- ---------------------------------- 1 a 2 a 3 a 4 w Elapsed: 00:00:00. 05 Execution Plan -------------------------------------------------------- Plan hash value: 1601196873 Bytes | Id | Operation | Name | Rows | Bytes | Cost (% CPU) | Time | ------ ------------------------------------------------------------------ | 0 | select statement | 4 | 20 | 3 (0) | 00:00:01 | 1 | table access full | T | 4 | 20 | 3 (0) | 00:00:01 | Statistics ---------------------------------------------------------- 0 recursive cballs 0 db block gets 7 consistent gets 0 physical reads 0 redo Size 672 bytes sent via SQL * Net to client 519 bytes provisioned ed via SQL * Net from client 2 SQL * Net roundtrips to/from client 0 sorts (memory) 0 sorts (disk) 4 rows processed 0 recursive cballs: Number of additional SQL statements executed in oracle during the execution of this SQL statement. 0 db block gets: number of data blocks read from the buffer cache (number of reads through update/delete/select for update ). 7 consistent gets: Number of undo data blocks read from the buffer cache (the number of select reads without for update ). 0 physical reads: number of data blocks read from the hard disk. 0 redo size: the size of the redo generated during SQL Execution. 672 bytes sent via SQL * Net to client: number of bytes sent to the client through SQL * Net. 519 bytes received ed via SQL * Net from client: the number of bytes received by the client through SQL * Net. 2 SQL * Net roundtrips to/from client: Number of Network round trips. (The arraysize parameter can be used in SQL * plus .) 0 sorts (memory): number of memory sorting records. 0 sorts (disk): number of disk sorting records. 4 rows processed: Number of actually returned records.