SQL 执行语句还是运行脚本?

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

Execute Statement or Run Script?

sqldatabaseoracleoracle-sqldeveloper

提问by vipirtti

While entering a SQL statement in Oracle SQL Developer, I noticed that I have two choices. I can either "Run Statement" or "Run Script". A similar choice seems to be available in SQL Maestro as well, although named "Execute query" and "Execute as script".

在 Oracle SQL Developer 中输入 SQL 语句时,我注意到我有两个选择。我可以“运行语句”或“运行脚本”。SQL Maestro 中似乎也提供了类似的选择,尽管名为“执行查询”和“作为脚本执行”。

What exactly is the difference between the two?

两者之间究竟有什么区别?

回答by Greg Reynolds

Run Statementwill give you a list of all the results in a sortable table. It will also only run the statement under the cursor (or highlighted). You will be prompted for bind variables when you run the statement (any place holder with : in front of it).

Run Statement将在可排序的表格中为您提供所有结果的列表。它也只会运行光标下(或突出显示)的语句。运行语句时,系统会提示您输入绑定变量(任何前面带有 : 的占位符)。

E.g.

例如

select * from customers where customer_id = :id

will prompt for a value for id

将提示输入 id 的值

Run Scriptwill execute all statements in the worksheet, and give a text readout of the results. It will not prompt you for the values of bind variables.

Run Script将执行工作表中的所有语句,并给出结果的文本读数。它不会提示您输入绑定变量的值。

回答by waney

I think "Execute Statement" - mean if you want to get results (resultset) "Run Script" - is something you need to execute but don't need a results, like installing database dump, or upgrade script to add columns to the table etc.

我认为“执行语句”——意思是如果你想得到结果(结果集)“运行脚本”——是你需要执行但不需要结果的东西,比如安装数据库转储,或升级脚本以向表中添加列等等。