将SQL文件保存到Oracle中的特定文件夹中(Saving SQL files into specific folders in Oracle)

我正在使用Oracle 11g 。 当我打开一个写入命令的新SQL文件时

ed filename.sql

我的bin文件夹中创建了一个新文件,其名称为filename但为了方便起见,我希望它们位于不同的文件夹中。 我正在开发3个应用程序(仅适用于我的练习)。 我希望它们存储在每个项目的不同文件夹中。 我尝试了以下所有这些都没有工作请告诉我如何将文件保存到特定的文件夹。

ed erp/logindetails.sql ed 'erp/logindetails.sql' ed "erp/logindetails.sql" ed 'erp\logindetails.sql' ed erp\logindetails.sql

除了我使用""之外的这些命令工作并打开了名为afiedt.buf的默认文本编辑器,当我只输入edit时我得到了这个afiedt.buf 。 使用上述任何命令都不会创建任何文件。

I am using Oracle 11g. When I open a new SQL file writing the command

ed filename.sql

A new file is created in my bin folder with the name as filename but, I want them to be in separate folders for my convenience. I am developing 3 application(well for my practice only). I want them to store in different folders for each project. I tried all of the following none of them worked please tell me how can I save the files into specific folders.

ed erp/logindetails.sql ed 'erp/logindetails.sql' ed "erp/logindetails.sql" ed 'erp\logindetails.sql' ed erp\logindetails.sql

These commands except where I used "" worked and opened the default text editor with the name afiedt.buf which I am getting when I enter only edit. No files are created with any of the above command.

最满意答案

你给EDIT一个文件的相对路径; 因为您当前的工作目录似乎是SQL * Plus目录所在的bin目录(这是Windows,并且您运行的是设置工作目录的快捷方式,可能吗?),它将尝试创建类似%ORACLE_HOME%\bin\erp\logindetails.sql的文件%ORACLE_HOME%\bin\erp\logindetails.sql ,你不太可能在那里创建一个erp目录。 提供目录的完整路径将起作用:

edit c:\users\dibya\projects\erp\logindetails.sql

例如。

如文档中所述, EDIT将搜索现有文件,但这涉及设置环境变量 - 在项目之间移动时必须更改这些变量。 您可能会发现在OS中编辑文件更容易,只需从SQL * Plus运行它们即可。

您也可以使用单独的快捷方式为每个项目启动SQL * Plus,每个项目都将'start in'目录设置为项目特定的位置 - 然后只需edit logindetails.sql ,默认情况下会查找正确的位置。 或者,从命令提示符cd进入相关的项目特定目录并从那里启动SQL * Plus,这实际上是一个快捷方式。

You're giving EDIT a relative path to the file; since your current working directory seems to be the bin directory that the SQL*Plus directory is in (is this Windows, and are you running a shortcut that sets the working directory, maybe?) it will try to create a file like %ORACLE_HOME%\bin\erp\logindetails.sql, and you're unlikely to have created an erp directory there. Giving the full path to the directory will work:

edit c:\users\dibya\projects\erp\logindetails.sql

for example.

As noted in the documentation, EDIT will search for existing files, but that involves setting an environment variable - which you'd have to change as you move between the projects. You might find it easier to edit the files in the OS and just run them from SQL*Plus.

You might also be able to use separate shortcuts to launch SQL*Plus for each project, each setting the 'start in' directory to a project-specific location - then just edit logindetails.sql would be looking in the right place by default. Or, from a command prompt cd into the relevant project-specific directory and launch SQL*Plus from there, which is effectively what a shortcut would do.

更多推荐