首页 » ORACLE » sqlplus environment $SQLPATH login.sql

sqlplus environment $SQLPATH login.sql

常用sqlplus 每次可能都要set pagesize \set linesize \set serveroutput很麻烦,sqlplus 允许每次启动都是会查找一个login.sql的文件自动格式化这些变量,从当前目录查找,也可以指定SQLPATH变量批定login.sql存放路径,这样从哪个目录进sqlplus都可以找到。

SQLPATH [SQL*Plus]

When an SQL script file (a file containing SQL statements) is executed with start, the file is searched in the current directory and the directory specified with the environment variable SQLPATH. (On Windows, it’s also possible to specify these directory via the registry.

Starting SQL*PLUS

Whenever SQL*Plus is started, it looks for a file named login.sql in the directory specified with $SQLPATH and, if existant, executes it.

On Windows…

On Windows, there is also the possibility to set the SQLPATH in the registry:

HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\{oracle_home}\SQLPATH

on linux

export SQLPATH=/xxxx

分享tom的设置,当然可以根据自己的使用习惯定义

———login.sql————–

define _editor=vi
set serveroutput on size 1000000
set trimspool on
set long 5000
set linesize 150
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

打赏

目前这篇文章有4条评论(Rss)评论关闭。

  1. anbob | #1
    2011-11-15 at 11:51

    再补充一下,sqlpath的目录是login.sql 文件所在的上层目录,不要带文件名,如
    export SQLPATH=/home/oracle/script

  2. saup007 | #2
    2011-11-15 at 11:14

    有几处符号,是中文状态输入的。
    —-
    define _editor=vim
    set serveroutput on size 1000000
    set trimspool on
    set long 5000
    set linesize 150
    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

  3. Egypt | #3
    2011-06-22 at 12:59

    There’s a srecet about your post. ICTYBTIHTKY

    • Fanny | #4
      2011-11-11 at 13:56

      You have shed a ray of snusihne into the forum. Thanks!