Set Env Var

$ vi $ORACLE_HOME/sqlplus/admin/glogin.sql
登陆sqlplus后会自动执行
$ vi ~/login.sql
登陆sqlplus后会自动执行
$ vi ~/.login.sql
登陆sqlplus后得手工执行


define _editor=vi
set timing on
set sqlprompt &_connect_identifier(&_user)>
set serveroutput on size 1000000 format wrapped
set linesize 32767
alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';


~/.bashrc


export PS1='\W \u($ORACLE_SID)]'

alias cdo='cd $ORACLE_HOME'
alias cda='cd /u01/app/oracle/admin'
alias sqlsys='sqlplus / as sysdba'
alias prod='export ORACLE_SID=PROD'
alias omr='export ORACLE_SID=OMR'
alias rac1='export ORACLE_SID=RAC1'
alias asm1='export ORACLE_SID=+ASM1'
alias rac2='export ORACLE_SID=RAC2'
alias asm2='export ORACLE_SID=+ASM2'


增加以下内容,sqlplus登陆时会自动读取


定义缓冲编辑器为vi
define_editor=vi
使DBMS_OUTPUT有效,并设置成最大buffer,并防止"吃掉"最前面的空格
set serveroutput on size 1000000 format wrapped
设置一行可以容纳的字符数
set linesize 256
设置一页有多少行数
set pagesize 50
设置来回数据显示量,这个值会影响autotrace时一致性读等数据
set arraysize 5000
页和页之间不设任何间隔
set newpage none
LONG或CLOB显示的长度
set long 5000
将SPOOL输出中每行后面多余的空格去掉
set trimspool on
设置查询耗时
set timing on
autotrace后explain plan output的格式
col plan_plus_exp format a120
在屏幕上暂不显示输出的内容,为下面的设置sql做准备
set termout off
设置时间格式
alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
获得用户名和global_name
col login_info_temp new_value login_info
select user||'@'||global_name login_info_temp from global_name;
设置sql提示为"user@global_name"
set sqlprompt '&login_info SQL> '
在屏幕上显示输出的内容
set termout on
列格式控制
col c1 format a1
col cc1 format a1
col c2 format a2
col cc2 format a2
col c3 format a3
col cc3 format a3
col c4 format a4
col cc4 format a4
col c5 format a5
col cc5 format a5
col c6 format a6
col cc6 format a6
col c7 format a7
col cc7 format a7
col c8 format a8
col cc8 format a8
col c9 format a9
col cc9 format a9
col c10 format a10
col cc10 format a10
col c15 format a15
col cc15 format a15
col c20 format a20
col cc20 format a20
col c30 format a30
col cc30 format a30
col c40 format a40
col cc40 format a40
col c50 format a50
col cc50 format a50
col c60 format a60
col cc60 format a60
col c70 format a70
col cc70 format a70
col c80 format a80
col cc80 format a80
col c90 format a90
col cc90 format a90
col c100 format a100
col cc100 format a100
col c150 format a150
col cc150 format a150
col c200 format a200
col cc200 format a200
col c255 format a255
col cc255 format a255
col host format a30
col db_link format a30
col host format a30
col db_link format a30
col member format a60
col name format a60
col owner format a15
col what format a90
col DEST_NAME format a30
col OS_USERNAME format a15
col USERNAME format a15
col USERHOST format a15
col TERMINAL format a15
col OBJ_NAME format a30
col SQL_TEXT format a60
col EVENT format a70
col status format a60
col MESSAGE format a100
col path format a30
col FILE_NAME format a60
col DESTINATION format a50
col OBJECT_NAME format a30


Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License