创建目录?
当我使用 sytem
用户创建目录时(vin.txt
是我的文件),
create directory emp_dir1
AS "'C:\Documents and Settings\Administrator\Desktop\vin.txt'";
它会创建它。
当我使用用户 Scott
执行相同操作时,它会给出文件路径错误,
"Identifier is too long"
但是当我将此文件路径放在单引号而不是 scott 的双引号中时,它会创建它。
背后的原因是什么?
When I create a directory using sytem
user (vin.txt
is my file)
create directory emp_dir1
AS "'C:\Documents and Settings\Administrator\Desktop\vin.txt'";
it creates it.
When I do the same using user Scott
it gives an error for path of file that
"Identifier is too long"
but when I put this file path in single quotes instead of double quotes for scott, it creates it.
What is the reason behind?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
关于你的问题,有几点让我担心。
首先,像 SCOTT 这样的普通用户不应该创建目录。 CREATE ANY DIRECTORY 非常强大,因为它赋予
oracle
帐户可访问的任何操作系统目录的读/写权限;这是一个巨大的安全漏洞。其次,目录路径必须只是路径,没有文件。我们使用 UTL_FILE、数据泵或其他方式创建文件。如果传递的 DIRECTORY 实际上是文件路径而不是操作系统目录,则对 UTL_FILE.FOPEN() 的调用将会失败。
我无法解释为什么 SYSTEM 成功执行的同一语句在 SCOTT 执行时会失败。我手头没有9i,所以无法测试。请剪切并粘贴整个 SQL*Plus 输出,以便我们可以看到发生了什么。正如彼得所指出的,您的问题似乎包含拼写错误,因此目前我们无法确定您认为正在发生的事情实际上正在发生。
A couple of things concern me about your question.
Firstly, regular users such as SCOTT should not be creating directories. The CREATE ANY DIRECTORY is extremely powerful, because it confers read/write privileges on any OS directory which is accessible to the
oracle
account; this is a massive security hole.Secondly, the directory path must be just the path, without a file. We create files using UTL_FILE, Data Pump or whatever. A call to
UTL_FILE.FOPEN()
will fail if the passed DIRECTORY is actually a path to a file not an OS directory.I cannot explain why the same statement executed successfully by SYSTEM fails when executed by SCOTT. I don't have 9i to hand, so I cannot test it. Please cut'n'paste the whole SQL*Plus output so that we can see what happens. As Peter has noted, your question appeared to contain a typo, so at the moment we cannot be certain that what you think is happening actually is what is happening.
为什么要使用双引号?
Oracle 中的字符串具有单引号,而双引号可用于列名和表名。
我使用
Oracle 10.2
进行了尝试(周围没有任何9g
),但无法重现这一点。无论我使用哪个用户,它都不起作用。当绳子和你的一样长时,我总是得到
当我尝试较短的路径 (
CREATE DIRECTORY emp_dir1 As "C:\vin.txt";
) 时,我得到Why are you using double-qoutes?
Strings in Oracle have single quotes, while double quotes can be used around column- and table-names.
I tried it using
Oracle 10.2
(don't have any9g
around), and I can't reproduce this. It's never working, no matter what user I use.When the string is as long as yours, I always get
When I try a shorter path (
CREATE DIRECTORY emp_dir1 As "C:\vin.txt";
) I get