在 Unix 机器上运行 sql plus 命令
我正在一台unix机器上工作,执行oracle sql命令的唯一方法是通过一个unix脚本,我们授予访问权限,如下所示:
#! /user/bin/ksh
User = 'PATH' # I can't read the file in this path
sqlplus $user << word # I don't know what it is used for
然后我开始编写sql命令,然后通过cmd执行脚本
我的问题是: 我有没有办法通过cmd直接通过上面的信息登录sqlplus
我尝试使用这个命令直接登录SQL*Plus:
sqlplus $user << word # I don't know what it is used for
但它提示 username: # 我不知道
I am working on a unix machine and the only way to execute oracle sql commands is through a unix script we grant access like this :
#! /user/bin/ksh
User = 'PATH' # I can't read the file in this path
sqlplus $user << word # I don't know what it is used for
And then I start writing sql commands then execute the script through cmd
My question is:
Do I have any way to login to sqlplus directly through the info above through cmd
I tried to use this command to log in directly to SQL*Plus:
sqlplus $user << word # I don't know what it is used for
But it prompted username: # which I don't know
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它告诉操作系统启动可执行文件“sqlplus”,将环境变量“$user”的值传递给它,然后重定向脚本下一行的其他输入,直到它涉及字符串文字“word”。这称为“输入重定向”,该行和以“word”开头的行之间的命令有时被称为““此处”文档”。使用字符串文字“word”来终止它充其量是奇怪和误导性的。大多数人使用“EOF”的某种变体来达到此目的。
我也不知道它预计将用于什么目的。在 *nix 中,环境变量(如文件名)区分大小写。因此,这个变量“user”与您在上一行中设置的变量“User”不同。
我不确定你的意思。你是说此时你的脚本有打算由 sqlplus 处理的 sql 命令吗?正如您使用输入重定向所表明的那样?
好吧,尽管存在所有其他问题,如果您不知道用户名和密码,您将永远无法连接到数据库。
It is telling the OS to launch the executable 'sqlplus', pass it the value of the environment variable "$user", then redirect other input from the next lines of the script until it comes to the string literal 'word'. This is call 'input redirection, and the commands between this line and the line beginning with the word 'word' are sometimes referred to as "a 'here' document". Using the string literal 'word' to terminate it is wierd and misleading at best. Most people use some variation of 'EOF' for this purpose.
I don't know what it is expected to be used for either. In *nix, environment variables (as are file names) are case sensitive. So this variable , "user" is not the same variable, "User" as you set in the previous line.
I'm not sure what you mean by this. Are you saying that at this point, your script has sql commands intended to be processed by sqlplus? As indicated by your use of input redirection?
Well, in spite of all the other issues, if you don't know the username and password, you will never be able to connect to the database.
如果你的unix机器设置正确,变量PATH应该包含/usr/local/bin,你可以通过输入命令echo $PATH来测试。
如果它的设置,oracle 文件 oraenv 中的源代码如下所示
。 oraenv
请注意,句点与单词 oraenv 之间应该有一个空格。通过这样做,它应该将目录 $ORACLE_HOME:$ORACLE_HOME/bin 附加到 PATH 变量。由于 sqlplus 位于 $ORACLE_HOME/bin 中,现在应该可以找到它。
我不建议偏离这个标准。您应该与您的 unix 管理员和 Oracle dba 联系以确保设置正确
If your unix box is setup correctly the variable PATH should include /usr/local/bin you can test by typing in the command echo $PATH.
if its setup, the source in the oracle file oraenv like so
. oraenv
Note there should be a space between the period a the word oraenv. By doing this it should append the directories $ORACLE_HOME:$ORACLE_HOME/bin to the PATH variable. Since sqlplus is in $ORACLE_HOME/bin it should now be found.
I wouldn't recommend deviating from this standard. You should speak to your unix admin and Oracle dba to make sure this is setup correctly