Oracle sqlplus login. SQL settings, sqlpluslogin. SQL
Sqlplus automatically runs two scripts at startup: glogin. SQL and login. SQL.
The execution order is
1. The glogin. SQL file is searched for and executed in the $ ORACLE_HOME/sqlplus/admin path by default.
2. By default, the login. SQL file is searched in the current path for execution. If the corresponding file is not found, execute 3.
3. Determine whether to set the SQLPATH environment variable. If this variable is set, search for and execute it in the corresponding path. If it is not found, stop searching.
You can add some common settings in the login. SQL file to make it easier to use SQLPLUS. The following experiment is performed on ORACLE 11.2.0.1.0.
The glogin. SQL file exists in the $ ORACLE_HOME/sqlplus/admin path by default.
Set the SQLPATH environment variable export SQLPATH = $ ORACLE_HOME/sqlplus/admin: $ SQLPATH in the profile file of the current user.
Add our own login. SQL file to the default path. The following configuration is a common Configuration:
-- The default editor of SQLPLUS is videfine _ editor = vi -- DBMA_OUTPUT is enabled by default, so you do not need to enter this command every time, at the same time, set the default buffer pool as large as possible set serveroutput on size 1000000 -- when the text is output offline, spaces at both ends of the text line are removed, and the row width is not fixed, if it is set to off (default ), the width of the text line output from the dummy line is equal to the configured linesizeset trimspool on -- set the default number of bytes displayed when the LONG and CLOB columns are selected set long 5000 -- set the displayed text width to 200 characters. linesize200-- Set how often SQLPLUS prints the title. set this parameter to a greater value so that only the title set pagesize 9999 is displayed on each page. -- set AUTOTRACE to get the default width of explain Plan output, generally, 80 is enough to put down the entire plan column plan_plus_exp format a80 -- set the SQLPLUS prompt. The display format is user @ database name column global_name new_value gnameset termout offdefine gname = idlecolumn global_name new_value gnameselect lower) | '@' | substr (global_name, 1, decode (dot, 0, length (global_name), dot-1) global_namefrom (select global_name, instr (global_name ,'. ') dot from global_name); set sqlprompt' & gname> 'set termout on
After using the scott user to log on
[oracle@RHEL65 ~]$ sqlplus scott/oracleSQL*Plus: Release 11.2.0.1.0 Production on Sat Jan 23 00:11:26 2016Copyright (c) 1982, 2009, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsscott@ORCL>select * from emp; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO---------- ---------- --------- ---------- ------------------- ---------- ---------- ---------- 7369 SMITH CLERK 7902 1980-12-17 00:00:00 800 20 7499 ALLEN SALESMAN 7698 1981-02-20 00:00:00 1600 300 30 7521 WARD SALESMAN 7698 1981-02-22 00:00:00 1250 500 30 7566 JONES MANAGER 7839 1981-04-02 00:00:00 2975 20 7654 MARTIN SALESMAN 7698 1981-09-28 00:00:00 1250 1400 30 7698 BLAKE MANAGER 7839 1981-05-01 00:00:00 2850 30 7782 CLARK MANAGER 7839 1981-06-09 00:00:00 2450 10 7788 SCOTT ANALYST 7566 1987-04-19 00:00:00 3000 20 7839 KING PRESIDENT 1981-11-17 00:00:00 5000 10 7844 TURNER SALESMAN 7698 1981-09-08 00:00:00 1500 0 30 7876 ADAMS CLERK 7788 1987-05-23 00:00:00 1100 20 7900 JAMES CLERK 7698 1981-12-03 00:00:00 950 30 7902 FORD ANALYST 7566 1981-12-03 00:00:00 3000 20 7934 MILLER CLERK 7782 1982-01-23 00:00:00 1300 1014 rows selected.scott@ORCL>set autot trace exp stat;scott@ORCL>select * from emp;14 rows selected.Execution Plan----------------------------------------------------------Plan hash value: 3956160932--------------------------------------------------------------------------| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |--------------------------------------------------------------------------| 0 | SELECT STATEMENT | | 14 | 532 | 3 (0)| 00:00:01 || 1 | TABLE ACCESS FULL| EMP | 14 | 532 | 3 (0)| 00:00:01 |--------------------------------------------------------------------------Statistics---------------------------------------------------------- 0 recursive calls 0 db block gets 8 consistent gets 0 physical reads 0 redo size 1630 bytes sent via SQL*Net to client 524 bytes received via SQL*Net from client 2 SQL*Net roundtrips to/from client 0 sorts (memory) 0 sorts (disk) 14 rows processedscott@ORCL>
After logon, you can see that SQLPLUS is configured according to the login. SQL file.