login.sql所在的位置 顯示當前連線的oracle SID及使用者命令 轉載

warehouse發表於2016-07-23

http://blog.csdn.net/yabingshi_tech/article/details/8979377

當退出或關閉sqlplus的時候,之前設定的命令就不再被保留了。為了避免每次使用SQLPLUS時都重新敲入一遍這些設定命令,可以建立一個login.sql檔案。

這個檔案必須放在sqlplus的啟動資料夾中或者包含在環境變數sqlpath所指向的資料夾路徑中。

glogin.sql 的檔案位置固定,在$ORACLE_HOME/sqlplus/admin 下面

login.sql的位置不固定,一般將login.sql放在執行sqlplus 的當前目錄(用pwd檢視當前目錄),即:/home/oralce

比如:我oracle裝在windows系統E:\ORACLE下,我可以在E盤或者其子資料夾下建login.sql檔案。裡面寫一句命令,如set timing on;

建完之後,cmd,進入命令視窗,

C:\Documents and Settings\Administrator>e:

E:\>cd oracle

E:\oracle>sqlplus scott/tiger

SQL*Plus: Release 10.2.0.1.0 - Production on 星期一 5月 27 12:55:

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


連線到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Produ
With the Partitioning, OLAP and Data Mining options

SQL> select * from tab;

TNAME                          TABTYPE  CLUSTERID
------------------------------ ------- ----------
DEPT                           TABLE
EMP                            TABLE
BONUS                          TABLE
SALGRADE                       TABLE

已用時間:  00: 00: 00.01

發現生效了。(*^__^*) 嘻嘻……

 

要想顯示當前連線的oracle SID及使用者,可以在LOGIN.SQL裡寫如下命令:

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

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/19602/viewspace-2122417/,如需轉載,請註明出處,否則將追究法律責任。

相關文章