在 Unix 机器上运行 sql plus 命令

发布于 2025-01-16 20:36:23 字数 526 浏览 1 评论 0原文

我正在一台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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

差↓一点笑了 2025-01-23 20:36:23

User = 'PATH' # 我无法读取该路径中的文件
没有文件可供读取。您正在将字符串文字“PATH”分配给环境变量“User”。您也可以说“User = 'FUBAR'”

sqlplus $用户<< word # 我不知道它是用来做什么的

它告诉操作系统启动可执行文件“sqlplus”,将环境变量“$user”的值传递给它,然后重定向脚本下一行的其他输入,直到它涉及字符串文字“word”。这称为“输入重定向”,该行和以“word”开头的行之间的命令有时被称为““此处”文档”。使用字符串文字“word”来终止它充其量是奇怪和误导性的。大多数人使用“EOF”的某种变体来达到此目的。

我也不知道它预计将用于什么目的。在 *nix 中,环境变量(如文件名)区分大小写。因此,这个变量“user”与您在上一行中设置的变量“User”不同。

然后我开始编写sql命令,然后通过执行脚本
命令

我不确定你的意思。你是说此时你的脚本有打算由 sqlplus 处理的 sql 命令吗?正如您使用输入重定向所表明的那样?

但它提示用户名:#我不知道

好吧,尽管存在所有其他问题,如果您不知道用户名和密码,您将永远无法连接到数据库。

User = 'PATH' # I can't read the file in this path
There is no file to read. You are assigning the string literal 'PATH' to the environment variable "User". You could just as well say "User = 'FUBAR'"

sqlplus $user << word # I don't know what it is used for

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.

And then i start writing sql commands then execute the script through
cmd

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?

But it prompted username : # which I don't know

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.

给妤﹃绝世温柔 2025-01-23 20:36:23

如果你的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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文