是否有 Oracle SQL 工具可以从结果集构建插入语句?

发布于 2024-07-16 15:10:26 字数 130 浏览 6 评论 0原文

是否有 Oracle SQL 工具可以从结果集构建插入语句? 目前我们只能使用一个名为 SQL Station 的工具。 我想推荐一个工具,比如 Rapid SQL 或 CrazySQuirrell,或者构建我自己的可重复使用的 sql 块。

Is there an Oracle SQL tool that builds insert statements from a result set? We are currently only allowed to use a tool called SQL Station. I'd like to either suggest a tool, like Rapid SQL or CrazySQuirrell, or build my own re-usable chunk of sql.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(9

浅忆流年 2024-07-23 15:10:27

在紧要关头,使用字符串连接非常适合您想要构建的较小语句:

Select
    'Insert Into MyOtherTableTable Values(''' || MyMainTableColumn1 || ''' and ''' || MyMainTableColumn2 || ''')'
From MyMainTable

In a pinch, using string contatenation works great for smaller statements you want to build:

Select
    'Insert Into MyOtherTableTable Values(''' || MyMainTableColumn1 || ''' and ''' || MyMainTableColumn2 || ''')'
From MyMainTable
浅暮の光 2024-07-23 15:10:27

右键单击查询的结果集,您将弹出一个窗口。 选择导出数据并插入。 它会询问您生成插入语句的文件的保存位置。 给出文件名和保存路径。

Right click on the result set of the query, you will get a pop up. select export data and insert. it will ask you for the location to save the file in which insert statements are generated. give file name and the path to save it.

寄居人 2024-07-23 15:10:27

我知道为时已晚,但它可能对某人有帮助。
如果你去表里,你可以“导出”数据。 第二步是“指定数据”,您可以在其中添加一些过滤器。
这只适用于表数据。

干杯

I know it is too late but It could be helpfull for somebody.
If you go to the table, you can "export" the data. The second step is "Specify Data" where you can add some filters.
This only works for a table data.

Cheers

夜血缘 2024-07-23 15:10:27

使用 Oracle SQL-Developer 输入并作为脚本执行 (F5):

select /*insert*/ 
  * from dual;

输出:

 Insert into "dual" (DUMMY) values ('X');

您也可以尝试 /*csv*/" 或 /*html*/

源:http://www.thatjeffsmith.com/archive/2012/05/formatting-query-结果到 csv-in-oracle-sql-developer/

SELECT /*csv*/ * FROM scott.emp;
SELECT /*xml*/ * FROM scott.emp;
SELECT /*html*/ * FROM scott.emp;
SELECT /*delimited*/ * FROM scott.emp;
SELECT /*insert*/ * FROM scott.emp;
SELECT /*loader*/ * FROM scott.emp;
SELECT /*fixed*/ * FROM scott.emp;
SELECT /*text*/ * FROM scott.emp;

With Oracle SQL-Developer type and execute as script (F5):

select /*insert*/ 
  * from dual;

output:

 Insert into "dual" (DUMMY) values ('X');

you can try also /*csv*/" or /*html*/

source: http://www.thatjeffsmith.com/archive/2012/05/formatting-query-results-to-csv-in-oracle-sql-developer/

SELECT /*csv*/ * FROM scott.emp;
SELECT /*xml*/ * FROM scott.emp;
SELECT /*html*/ * FROM scott.emp;
SELECT /*delimited*/ * FROM scott.emp;
SELECT /*insert*/ * FROM scott.emp;
SELECT /*loader*/ * FROM scott.emp;
SELECT /*fixed*/ * FROM scott.emp;
SELECT /*text*/ * FROM scott.emp;
复古式 2024-07-23 15:10:26

这个结果集从哪里来? 如果您的意思是要执行 SELECT,然后将结果数据插入到另一个表中,您可以在单个 SQL 语句中执行此操作:

INSERT INTO table2 (columnA, columnB)
  SELECT columnA, columnB
    FROM table1;

Where is this result set coming from? If you mean that you want to execute a SELECT, then insert the resulting data into another table, you can do that in a single SQL statement:

INSERT INTO table2 (columnA, columnB)
  SELECT columnA, columnB
    FROM table1;
朮生 2024-07-23 15:10:26

PL/SQL Developer 也将执行此操作。 我使用过 PL/SQL Developer 和 Oracle 的 SQL Developer,在我看来,PL/SQL Developer 具有更流畅、更一致的界面。 不确定 SQL Developer,但不确定 PL/SQL Dev。 还允许您将结果集导出为 CSV、XML 和 HTML。

如果您运行的是 Linux,它在 WINE 下也可以正常运行。

PL/SQL Developer will do this as well. I've used both PL/SQL Developer as well as Oracle's SQL Developer, and in my opinion PL/SQL Developer has a smoother and more consistent interface. Not sure about SQL Developer, but PL/SQL Dev. also lets you export result sets as CSV,XML, and HTML.

It also behaves OK under WINE if you're running Linux.

淤浪 2024-07-23 15:10:26

如果您需要命令行工具,免费的 cx_OracleTools 可以做到这一点,还有其他一些好东西。

http://cx-oracletools.sourceforge.net/

  • CompileSource - 执行文件中的语句,检查错误
  • CopyData - 将数据从一个表或视图复制到另一个
  • DbDebugger - 允许对 PL/SQL 进行简单的调试
  • DealObject - 将对象描述为 SQL 语句以供重新创建
  • DescribeSchema - 将多个对象描述为 SQL 语句以进行重新创建
  • DumpCSV - 转储 select 语句的结果作为逗号分隔值
  • DumpData - 将 select 语句的结果转储为 insert 语句
  • ExportColumn - 将列中的数据转储到文件中
  • ExportData - 将数据库中的数据转储到可移植转储文件中
  • ExportObjects - 将对象描述为 SQL 语句以供重新创建文件
  • ExportXML - 将数据从表导出到简单的 XML 文件中
  • GeneratePatch - 生成 SQL 脚本以从一组对象转到另一组对象
  • GenerateView - 生成表的视图语句
  • ImportColumn - 将文件的内容导入到数据库中的列中
  • ImportData - 导入使用 ExportData 转储的数据
  • ImportXML - 从 XML 文件(例如由 ExportXML 创建的文件)导入数据
  • RebuildTable - 生成 SQL 脚本来重建表
  • RecompileSource - 重新编译数据库中的所有无效对象

If you want command line tools, the free cx_OracleTools will do this, and some other nice things as well.

http://cx-oracletools.sourceforge.net/

  • CompileSource - execute statements in a file, checking for errors
  • CopyData - copy data from one table or view to another
  • DbDebugger - allows simple debugging of PL/SQL
  • DescribeObject - describe objects as SQL statements for recreation
  • DescribeSchema - describe multiple objects as SQL statements for recreation
  • DumpCSV - dump the results of a select statement as comma separated values
  • DumpData - dump the results of a select statement as insert statements
  • ExportColumn - dump the data from a column into a file
  • ExportData - dump the data from a database into a portable dump file
  • ExportObjects - describe object as SQL statements for recreation in files
  • ExportXML - export data from a table into a simple XML file
  • GeneratePatch - generate SQL script to go from one set of objects to another
  • GenerateView - generate a view statement for a table
  • ImportColumn - import the contents of a file into a column in the database
  • ImportData - import the data dumped with ExportData
  • ImportXML - import data from an XML file (such as those created by ExportXML)
  • RebuildTable - generate SQL script to rebuild the table
  • RecompileSource - recompile all invalid objects in the database
送君千里 2024-07-23 15:10:26

是的,查看 Oracle sql Developer。可以从 otn.oracle.com 免费下载

Yes look at Oracle sql developer.Its free can be downloaded from otn.oracle.com

梦断已成空 2024-07-23 15:10:26

我找到了这个解决方案,这就是我现在正在使用的。 感谢您的所有帮助。
事实证明我们也可以使用 SQL+。 由于某种原因我无法在 SQL Station 中运行它。

从 userid/password@from_DB 复制到 userid/password>@to_DB INSERT toDB_tablename USING SELECT * FROM fromDB_tablename where ....;

犯罪;

I found this solution, which is what I'm using now. Thanks for all of the help.
It turns out we can use SQL+ too. For some reason I can't run it in SQL Station.

COPY FROM userid/password@from_DB TO userid/password>@to_DB INSERT toDB_tablename USING SELECT * FROM fromDB_tablename where ....;

commit;

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