ITPub博客

首页 > 数据库 > Oracle > [20211220]记录使用sqlplus的小问题.txt

[20211220]记录使用sqlplus的小问题.txt

原创 Oracle 作者:lfree 时间:2021-12-21 08:42:37 0 删除 编辑

[20211220]记录使用sqlplus的小问题.txt

--//记录工作中遇到的一个使用sqlplus的小问题,我现在开始经常在工作中使用tpt脚本。无意中如果在命令行加入参数会导致带入的参
--//数失效。通过例子说明问题。

1.环境:
SCOTT@book> @ver
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

2.测试:
$ cat mm.txt
select '&1' from dual;

$ rlsql -s -l scott/book @mm.txt aaaaaaaa
'NOWRA
------
nowrap
quit

--//按照道理应该输出我参数aaaaaaaa.实际上tp目录下有一个login脚本,自动初始化一些参数。
$ cat login.sql
-- Copyright 2018 Tanel Poder. All rights reserved. More info at http://tanelpoder.com
-- Licensed under the Apache License, Version 2.0. See LICENSE.txt for terms & conditions.

-- calling init.sql which will set up sqlpus variables
@init.sql
-- i.sql is the "who am i" script which shows your session/instance info and
-- also sets command prompt window/xterm title
-- @i.sql
-- you can put your own login scripts here

--//缺省登录后自动调用init.sql脚本,里面调用htmlset.sql:
@@htmlset nowrap "&_user@&_connect_identifier report"

--//htmlset 调用 htmlset2 命令:
@@htmlset2 &1 "&2" #f7f7e7 black

--//这样初始化后覆盖了参数1,2,3,4:
DEFINE 1               = "nowrap" (CHAR)
DEFINE 2               = "SCOTT@book report" (CHAR)
DEFINE 3               = "#f7f7e7" (CHAR)
DEFINE 4               = "black" (CHAR)

--//导致出现了我遇到测试遇到的情况。如何解决呢?

3.一种改名login.sql启动时不调用init.sql,修改为手动执行。
--//我尝试了许多,也没有什么好方法,也许只能手工执行init.sql,养成习惯也许就ok了.大家有什么好方法.
--//也给大家提一个醒,注意环境变量SQLPATH,以及sqlplus相关路径下的login.sql的自动执行.

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/267265/viewspace-2848574/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
熟悉oracle相关技术,擅长sql优化,rman备份与恢复,熟悉linux shell编程。

注册时间:2008-01-03

  • 博文量
    4006
  • 访问量
    7969264