sqlplus环境配置(login.sql)
2015-06-17 10:24
288 查看
(1)全局设置文件:$ORACLE_HOME/sqlplus/admin/glogin.sql
(2)个性化设置文件:login.sql,然后有操作系统环境变量指定其位置:
exportSQLPATH=/home/oracle/oracle_relate
常用的login.sql如下:(参考《OracleDatabse9i/10g/11g编程艺术》
define _editor=vi set serveroutput on size 1000000 set trimspool on set long 5000 set linesize 300 set pagesize 9999 column plan_plus_exp format a80 column global_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
说明:
(1)SET TRIMOUT ON SETTRIMSPOOL ON
SET TRIMOUT ON or SET TRIMSPOOL ON removes trailing blanks at the end of each displayed orspooled line.
Setting these variables ON can reduce the amount of datawritten. However, if LINESIZE is optimal, it may be faster to set the variablesOFF. The SQL*Plus output line is blank filled throughout the query processingroutines so removing the spaces could take
extra effort.
Trimout与trimspool分别处理标准终端输出与spool输出结尾处的空格是否去掉。若on,则去掉空格。若off,则不去掉空格,按照linesize的大小补充空格数量。
默认情况下,trimout on, trimspool off。
(2)column plan_plus_expformat a80
This sets the default width of the explainplan output we receive with AUTOTRACE. a80is generally wide enough to hold the full plan.
(3)set termout off
当设置为set termout off的时候就会忽略sql语句的输出如果这条sql是在脚本中运行的话。也就是说如果命令不在脚本中运行,即使设置为set termout off,仍然会返回sql的结果。
(4)设置SQL提示符
以下内容用于定义SQL提示符:
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 (selectglobal_name, instr(global_name,'.') dot from global_name ); set sqlprompt'&gname> ' set termout on
The directive column global_name new_valuegname tells SQL*Plus to take the last value it retrieves for any column named global_name,and place it into the substitution variable gname. I then select the global_nameout of the database, and concatenate this
with the username I am logged inwith. That makes my prompt look like this
ops$tkyte@ora11gr2>
so I know who I am as well as where I am.
其实可简单改为:
select lower(user) || '@'||global_name from global_name;
即可得到以下结果:
sys@NFIRMS
相关文章推荐
- Oracle从软件安装到运行的全流程
- 【转载】linux中误删除oracle数据文件的恢复操作
- Oracle 字符集的查看和修改
- NOSQL Mongo入门学习笔记 - C++连接Mongodb(三)
- Oracle 中 where 与 having 之间的区别
- 在AIX环境为Oracle表空间增加裸设备(逻辑卷)
- 使用sys无法通过sqlplus或者sqldeveloper连接数据库
- Oracle学习计划
- SQL语句、PL/SQL语句、SQL*PLUS语句结束符号
- 数据库崩溃后对redo log的使用
- Redis,Memcache,mongoDB的区别
- redis 在centos下的安装部署
- 深入浅出Mybatis-sql自动生成
- How To Use TKPROF To Trace And Analyze Sql Explan
- 数据库操作
- Redis备份还原
- MySQL性能优化的最佳20+条经验(1)
- MySQL性能测试工具之mysqlslap
- Redis学习第三课:Redis Hash类型及操作
- 数据库字符集修改