oracle Oracle中TNS_ADMIN变量有什么用?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1818016/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 19:32:48  来源:igfitidea点击:

What is the use of TNS_ADMIN variable in Oracle?

oracleunixshellconnectionsqlplus

提问by Sachin Chourasiya

Please tell me what is the use of TNS_ADMIN parameter in Oracle? I am working on Unix using oracle database.

请告诉我 TNS_ADMIN 参数在 Oracle 中的用途是什么?我正在使用 oracle 数据库在 Unix 上工作。

Is this parameter is required to locate the sqlplus. I am executing a script in which a update query is executed on Oracle Database.

是不是需要这个参数来定位sqlplus。我正在执行一个脚本,其中在 Oracle 数据库上执行更新查询。

The script fails with 127 error code when executed with crontab.

使用 crontab 执行时,脚本失败并显示 127 错误代码。

The script contents I suspect (eval) failing are

我怀疑(eval)失败的脚本内容是

----------
cmd='sqlplus ${ORALOGIN} < SQLS
----------
eval $cmd

回答by Philip Schlump

TNS_ADMIN tells sqlplus where to find the tnsnames.ora file.

TNS_ADMIN 告诉 sqlplus 在哪里可以找到 tnsnames.ora 文件。

If you are running sqlplus from a crontab then the normal reason for having difficulty are:

如果您从 crontab 运行 sqlplus,那么遇到困难的正常原因是:

  1. Incorrect path
  2. Not having the correctly set ORACLE_SID or other Oracle connection information
  3. A startup/login script that is getting executed when you login to the system that is interfering with your cron execution
  4. Some script that you run from the command line when you login that sets up your Oracle environment that is not getting executed in your crontab.
  1. 路径不正确
  2. 没有正确设置 ORACLE_SID 或其他 Oracle 连接信息
  3. 当您登录到干扰您的 cron 执行的系统时正在执行的启动/登录脚本
  4. 登录时从命令行运行的一些脚本,用于设置未在 crontab 中执行的 Oracle 环境。

Check these things and other environment related items. It always takes me a number of passes to get crontab and Oracle to work happily together.

检查这些东西和其他与环境相关的项目。我总是需要多次通过才能让 crontab 和 Oracle 愉快地协同工作。