oracle SQLDeveloper 是否支持执行脚本?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/288988/
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-10 01:38:01  来源:igfitidea点击:

Does SQLDeveloper support executing scripts?

oraclesqlplusoracle-sqldeveloper

提问by thursdaysgeek

I was trying to follow some instructions today, and it starts with the comment

我今天试图遵循一些说明,它从评论开始


REM  In SQLPlus I manually copy in each line and execute it.

That's nice, I don't have SQLPlus, I have SQLDeveloper. The lines that were pasted in were of the type:

太好了,我没有 SQLPlus,我有 SQLDeveloper。粘贴的行属于以下类型:


@\server\dir\dir\dir\commandfile1.txt;
COMMIT;

...etc.

...等等。

It didn't like it when I tried that in a SQL window. I opened up and pasted in the commands by hand, and it wasn't happy with that either. (Did I mention that I'm not so good with this application nor Oracle, but that everyone else was out today?) The files there started with code like:

当我在 SQL 窗口中尝试时,它不喜欢它。我打开并手动粘贴命令,它也不满意。(我有没有提到我对这个应用程序和 Oracle 不太熟悉,但今天其他人都出去了?)那里的文件以如下代码开头:


rem
set echo on
rem
execute procedure_name ('parameter1', 'parameter2');

A co-worker did have SQLPlus, and together we got it resolved. But, is there a way for me to do this with SQLDeveloper, so I'm not stuck if he's out too?

一位同事确实有 SQLPlus,我们一起解决了这个问题。但是,有没有办法让我用 SQLDeveloper 做到这一点,所以如果他也出去了,我也不会被卡住?

回答by user313218

To run scripts in SQL Developer:

在 SQL Developer 中运行脚本:

@"\Path\Scriptname.sql"

(You only need the quotes if there are any spaces)

(如果有任何空格,您只需要引号)

You can set a default Path: Tools menu > Preferences > Database > Worksheet > Select default path to look for scripts

您可以设置默认路径:工具菜单>首选项>数据库>工作表>选择默认路径以查找脚本

回答by Hymanet_and_hat

I was looking through the help files and found how to do it in SQL Developer Concepts and Usage->Using the SQL Worksheet->Script Runner.

我正在查看帮助文件,并在 SQL Developer Concepts and Usage->Using the SQL Worksheet->Script Runner 中找到了如何执行此操作。

Basically, you have to precede the file name with an @. For example @C:\MyScript\Script.sql.

基本上,您必须在文件名前面加上@。例如@C:\MyScript\Script.sql。

You can then run a batch of them this way. Note that the command doesn't seem to like spaces in the file path.

然后,您可以通过这种方式运行一批。请注意,该命令似乎不喜欢文件路径中的空格。

回答by Leigh Riffel

For each file you need to run, find it and drop it into SQLDeveloper. Run the script (F5) and then commit (F11). This will work for some scripts, but not all.

对于您需要运行的每个文件,找到它并将其放入 SQLDeveloper。运行脚本 (F5),然后提交 (F11)。这适用于某些脚本,但不是全部。

回答by hughk

SQL Developer these days comes with another tool called sqlcl. This is a bit like SQLPlus but is actually using some bits from SQL Developer to give a compatible command line/scripting type interface.

如今,SQL Developer 附带了另一个名为sqlcl 的工具。这有点像 SQLPlus,但实际上是使用 SQL Developer 的一些位来提供兼容的命令行/脚本类型接口。

You would be able to use it to execute sqlplus style commands without fighting the extras of the SQL Developer style GUI which can get confusing.

您将能够使用它来执行 sqlplus 样式命令,而无需与 SQL Developer 样式 GUI 的附加功能进行斗争,这可能会令人困惑。

Look for it under wherever SQL Developer is sitting. If you don't have it there, you can download it and deploy it into your sqldeveloper folder.

在 SQL Developer 所在的任何地方查找它。如果那里没有它,您可以下载它并将其部署到您的 sqldeveloper 文件夹中。

回答by Jorge Moreno

you can do it using sqlcl in the same way how you would do it using SQL PLUS, from command line:

您可以使用 sqlcl 以与使用 SQL PLUS 相同的方式从命令行执行此操作:

sqlcl user/password@host:port:sid @file.sql

file should be in the same directory where sqlcl is.

文件应该在 sqlcl 所在的同一目录中。

This solution is the best option if you are trying to execute a lot of instruction on sql file.

如果您尝试在 sql 文件上执行大量指令,则此解决方案是最佳选择。

回答by David Aldridge

This would do it:

这样做:

begin
    procedure_name ('parameter1', 'parameter2');
end;
/