sqlplus之glogin.sql and login.sql

sqlplus在被执行时,都会执行glogin.sql, 若执行sqlplus的当前目录下有login.sql, 那么login.sql也会被执行。
glogin.sql:
-- DESCRIPTION
--   SQL*Plus global login "site profile" file
--
--   Add any SQL*Plus commands here that are to be executed when a
--   user starts SQL*Plus, or uses the SQL*Plus CONNECT command.
--
-- USAGE
--   This script is automatically run

所以, glogin.sql是全局的, 当sqlplus被启动时,里面的命令都会被执行; glogin.sql位于$ORACLE_HOME/sqlplus/admin下;
login.sql文件中的所有命令的优先级都比glogin.sql中的高。即glogin.sql中的命令会先被执行,若login.sql中的命令会后执行,若login.sql和glogin.sql有重复的命令,那么login.sql中的命令会覆盖glogin.sql中的命令. 
login.sql位于执行sqlplus的当前目录下.

测试如下:
1.glogin.sql没有任何内容
[oracle@myoracle admin]$ cat $ORACLE_HOME/sqlplus/admin/glogin.sql
 
[oracle@myoracle admin]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Sat Jul 6 17:51:33 2013

Copyright (c) 1982, 2009, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> show linesize
linesize 80
SQL> 

2. 现在修改glogin.sql, 增加"set linesize 100"
[oracle@myoracle admin]$ cat $ORACLE_HOME/sqlplus/admin/glogin.sql
set linesize 100

[oracle@myoracle admin]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Sat Jul 6 17:55:53 2013

Copyright (c) 1982, 2009, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> show linesize
linesize 100

3. 现在在运行sqlplus的当前目录创建login.sql, 并在里面添加"set linesize 200"

[oracle@myoracle feng]$ pwd
/home/oracle/feng

[oracle@myoracle feng]$ cat login.sql 
set linesize 200

这时,再运行sqlplus,查看linesize的值

[oracle@myoracle feng]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Sat Jul 6 18:00:02 2013

Copyright (c) 1982, 2009, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> show linesize
linesize 200



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值